Forum Discussion
VBA code message box
No VBA needed.
Select columns A to C. The active cell in the selection should be in row 1.
On the Data tab of the ribbon, click Data Validation.
Select Custom from the Allow drop-down.
Enter the following in the Formula box:
=NOT(AND(OR($A1="Boston",$A1="Antwerp",$A1="Berlin"),OR($B1="red",$B1="blue",$B1="green"),$C1="Yes"))
Activate the Error Alert tab.
Enter an appropriate message.
Click OK.
- Greeny95Apr 25, 2022Copper Contributor
Hi Hans (per toeval Nederlands-sprekend?)
Thanks for your answer!
I tried your solution. And it worked but: in one of the columns I use already data validation with a list. When I use your solution I can't use the dropdown menu anymore in that column.
That's why I think I need a macro. Unless there is another solution?
Kind regads
Manu (Greeny95)
- HansVogelaarApr 25, 2022MVP
Ik ben Nederlands, trouwens...
- Greeny95Apr 28, 2022Copper ContributorHi Hans,
I found time again to work on my excel. Busy times...
Your VBA code works perfect. Wauw! Thanks a lot. I've two more little questions. I run also another VBA code in the same sheet. I copied your code on the same page. Now I get the message: compileerfout: onduidelijke naam gedetectreerd: Worksheet_Change. The two codes start with the same name. I tried to change one of them by adding a "2" but then, the code with the changed name don't work anymore.
And another small thing: I like to add one more "and" condition. Row D are dates. So when the 3 previous conditions are true AND it's a sunday then I need the warning to pop up. I hoped it was something like 'WEEKDAG("D")=1 ' but it wasn't that easy. I hope you can help me one more time! Thanks. Manu
- HansVogelaarApr 25, 2022MVP
You are correct - data validation of type Custom cannot be combined with data validation of type List.
Here is a VBA-based idea.
- Greeny95Apr 25, 2022Copper ContributorHansVogelaar: I forgot to mention this: as it happens that a person made the wrong choice, the 3 cells (A1,B1 and C1) get a red colour. (with conditional formatting) Is that something that can trigger a message box?