Hello,
I am trying to make a macro that will go through a range and count all cells that meet a criteria. I need the function to take a integer that represents a date and compare it to today. The dates are in a format of mmddyyyy such as 12132011 for today 1012012 for 1/1/2012. Below is the code that I have written:
Sub getLate()
Dim cnt As Integer
Dim c As Range
cnt = 0
For Each c In Range(Range("F10"), Range("A9").End(xlDown).Offset(0, 6))
If DateDiff("d", DateValue(Str(c.Value).Format("00-00-0000")), Date) >= 30 Then
cnt = cnt + 1
End If
Next
MsgBox cnt
End Sub
Any help will be greatly appreciated.
Thank you!
Bookmarks