Wee Kuang
Board Regular
- Joined
- Sep 15, 2011
- Messages
- 59
Hello all,
Currently I'm trying to come up with a macro that is able to do some highlighting to cells, which contain dates that are two weeks past the current date. Below is my progress so far.
Sub date_highlight()
CurrentDate = Date
LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For n = 3 To LastRow
If Range("J" & n).Value < CurrentDate + 1 And Range("J" & n).Value > CurrentDate - 15 Then
Range("J" & n).Style = "Good"
End If
Next n
End Sub
When I run the macro, it keeps on showing a Run-time error '1004': Application-defined or object defined error.
I'm quite new to VBA and so any guidance or help will be much appreciated. Cheers!
Currently I'm trying to come up with a macro that is able to do some highlighting to cells, which contain dates that are two weeks past the current date. Below is my progress so far.
Sub date_highlight()
CurrentDate = Date
LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For n = 3 To LastRow
If Range("J" & n).Value < CurrentDate + 1 And Range("J" & n).Value > CurrentDate - 15 Then
Range("J" & n).Style = "Good"
End If
Next n
End Sub
When I run the macro, it keeps on showing a Run-time error '1004': Application-defined or object defined error.
I'm quite new to VBA and so any guidance or help will be much appreciated. Cheers!
Last edited: