Scanning 3 columns for Dates

RompStar

Well-known Member
Joined
Mar 25, 2005
Messages
1,200
I have an Excel sheet, it's a .CSV file acctually.

There are 3 columns that have a combo Date Time in the cell contents, like this:

8/31/2006 10:37

I want to highlight those 3 columns, and make sure that the data in the sheet only contains 2006 dates and nothing else. There is a lot of rows, what's the best way to do this ?

I want to maybe highlight in bold the cells that are incorrect date, it dones't matter if it is before 2006 or past it, sometimes scanners reset and the date gets messed up.

Thank you for your help.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Hello RompStar,
Here are a couple ideas that come to mind.
If by "highlight those 3 columns" you mean to just highlight the range of interest (as opposed
to highlighting the entire columns) then something like this should work.
Code:
Sub CheckYearDemo()
Application.ScreenUpdating = False
Dim c As Range
For Each c In Selection
  If Year(c.Value) <> "2006" Then c.Font.Bold = True
Next c
Application.ScreenUpdating = True
End Sub

Now, if you want to make this a bit more dynamic by testing for the current year (ie, not
having to edit your code next year and so on) then you can simply replace the line:
If Year(c.Value) <> "2006" Then
with . .
If Year(c.Value) <> Year(Date) Then

And finally, if you know the columns in advance and don't want to have to highlight the range containing the dates then what are the columns & starting rows you're checking?
We can make it reference those down to the last used rows automatically.
 

Forum statistics

Threads
1,176,264
Messages
5,902,229
Members
434,952
Latest member
AlanN

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
Top