...so right-click the sheet's tab, select View Code, and paste in VBIDE.
When you right-click the sheet's tab and select View Code, this takes you to VBIDE; that is, the code editing window.
For a simple test, open a new/blank workbook and place this code in the sheet's module:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngMyUsedRange As Range
Dim rCell As Range
Set rngMyUsedRange = Range("A1:N40")
For Each rCell In rngMyUsedRange
If IsDate(rCell.Value) _
And rCell.Value < Date + 30 Then
rCell.Font.Color = &HFF&
End If
Next
End Sub
Now when you go back to the sheet, try typing in some dates in any cell in the range of A1:N40. The font will change to red presuming the date is less than 30 days from now.
Using the change event (in this second example) might be better, as the font will change as soon as the date is entered (after the cell (ie edit mode) is exited), rather than waiting til the next time the sheet is activated.
A couple of "maybe's" to consider:
- If you already know specific cells that dates will be entered in, you could specify to check just these cells.
- You might want to also change the font back to black if a new date is entered that is over 30 days out.
Mark