Check value in a cell vs Mid value in another

[Solved/Closed]
Report
-
Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
-
Hello,

I have months in column A in number format. Single digit for the first nine months and double digit for the last 3 months. In column B, I have date in DD.MM.YYYY (eg, 25.01.2011) format.

I need a VBA code that will throw an error message if the two out comes are same.
So for the April Month in column A will be 4 and column B will be 04, this will create an error message to check the work.

Please also note that column B needs to be stripped of 0 for the nine months check and then included for the last three months.

Thanks for your help,
student of VBA




1 reply

Posts
2818
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
October 18, 2021
486
Hi Student of VBA,

Sorry to disappoint you, but you don't need VBA for this. :(

I assume row 1 is used for header, so select B2.
Goto top menu > data > validate.
On the dropdown list "Allow" select the bottom option (manual adjust?)
Type in this formula:
=MONTH(B2)<>A2
On the right most tab (error message) of the validate window you can type in the error message.

Drag cell B2 down as far as needed and select "format only" from the small white square. The small white square appears when done dragging.

Don't understand the following:
quote
Please also note that column B needs to be stripped of 0 for the nine months check and then included for the last three months.
unquote
So you want 04 to be 4 and 10 to be 010???

Best regards,
Trowa