Check value in a cell vs Mid value in another

Solved/Closed
student of VBA - Apr 15, 2011 at 08:30 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Apr 15, 2011 at 09:55 AM
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




Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Apr 15, 2011 at 09:55 AM
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
0