Code To Highlight Cells With Date Errors

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
I have a large data file like below. I have a data column where there are errors where the end date is before the start date! I need a code please to highlight these.

StartEndDate
11/2013->12/2014
11/2013->02/2018
03/2013->11/2013
01/2017->12/2014
11/2013->02/2018
05/2013->11/2013
01/2017->12/2014

I have highlighted above what sort of format and errors occur. There are various columns of data either side but I can adapt the code to the column it needs to look at in each different file I use it on.

Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
i have used
=DATEVALUE("1/"&LEFT(A2,7)) > DATEVALUE("1/"&RIGHT(A2,7))

in a conditional formatting rule
Book4
ABCD
1StartEndDate
211/2013->12/20144197441579
311/2013->02/2018
403/2013->11/2013
501/2017->12/2014?
611/2013->02/2018
705/2013->11/2013
801/2017->12/2014?
Sheet2
Cell Formulas
RangeFormula
C2C2=DATEVALUE("1/"&RIGHT(A2,7))
D2D2=DATEVALUE("1/"&LEFT(A2,7))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A8Expression=DATEVALUE("1/"&LEFT(A2,7)) > DATEVALUE("1/"&RIGHT(A2,7))textNO
 
Upvote 0
I would prefer a macro if one is possible so I can put in my PMW for different files.
 
Upvote 0
not my area , my VBA is now to old

perhaps report this post and ask moderator for it to be closed

and then open a new one specifically asking for VBA in the title
 
Upvote 0
not my area , my VBA is now to old

perhaps report this post and ask moderator for it to be closed

and then open a new one specifically asking for VBA in the title
Thanks but I did ask for code and not formula.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top