Highlight cells using VBA

KirkComer

Registered User.
Local time
Today, 03:14
Joined
Oct 21, 2005
Messages
50
Can I highlight certains cells in a particular column using VBA?
I have attached a simple example.

I want to highlight "Due Date" cells that are older than 30 days that do not have a date entered under "Date Complete".

So in the attached example the only cell that should highlight would be A5
 

Attachments

Hi, KirkComer,

Conditional Formatting should do the job as well ;)

Sheet VBA uses the following code:

Code:
Sub PutCF()
Dim lngLast As Long
Dim lngCounter As Long

Application.ScreenUpdating = False
lngLast = Cells(Rows.Count, "A").End(xlUp).Row
For lngCounter = 2 To lngLast
  With Cells(lngCounter, "A")
    If .Value < Date - 30 And IsEmpty(.Offset(0, 1).Value) Then
      .Interior.ColorIndex = 3
    End If
  End With
Next lngCounter
Application.ScreenUpdating = True
End Sub
Ciao,
Holger
 

Attachments

Thank you soooo much!!! :)
 

Users who are viewing this thread

Back
Top Bottom