Excel Marcro Help. Highlight Invalid birthdates

xxcucumberxx

New Member
Joined
Feb 23, 2016
Messages
7
I really need someones help. I need a code for a macro to scan column M and highlight invalid birth-dates. Only to skip short date (by short date i mean is like this 01/01/1901) only that format, anything other than a shot date to highlight all the way down to the last row with data on it. Not to the end of the excel spreadsheet. Please help ive been trying for the pas week to figure it out but nothing seems to work. Thank you so much who can help!!@@
The code i used
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Dim c As Range

For Each c In Selection
If Not IsDate(c.Value) And c.Value <> vbNullString Then
c
.Font.ColorIndex = 3
End If
Next c</code>But its not finding all the invalid dates

Maybe there is a completely different macro i can use or something

If it can start the scan from column "M" Row "2"
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You could look at the number format of the cells within the range.

Code:
Sub TestDates()
Dim R As Long
Dim rng As Range

For R = 2 To Cells(Rows.Count, 13).End(xlUp).Row
    Set rng = Cells(R, 13)
    Select Case UCase(rng.NumberFormat)
        Case "MM/DD/YYYY", "M/D/YYYY"
        Case Else
            rng.Font.ColorIndex = 3
    End Select
Next R

End Sub

The first line of the code finds the absolute end of column number 13 "M" and moves up to the first non-blank cell and returns the row number of that cell.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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