Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Public Sub TestMe()
- ThisWorkbook.Date1904 = True 'this is dangerous!
- Cells.Clear
- Dim cnt As Long
- For cnt = 3 To 20
- Cells(1, cnt) = DateAdd("M", cnt, DateSerial(2016, 1, 1))
- Cells(1, cnt).NumberFormat = "MMM-YY"
- Next cnt
- Dim someDates(2) As Date
- someDates(0) = DateSerial(2016, 1, 1) 'exists
- someDates(1) = DateSerial(2012, 1, 1) 'does not exist
- someDates(2) = 1 '31.12.1899
- Dim foundRange As Range
- For cnt = LBound(someDates) To UBound(someDates)
- Set foundRange = Rows(1).Find(someDates(cnt))
- If Not foundRange Is Nothing Then
- foundRange.Interior.Color = vbRed
- End If
- Next cnt
- ThisWorkbook.Date1904 = False
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement