Highlight cells using VBA (1 Viewer)

KirkComer

Registered User.
Local time
Today, 13:21
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

  • Highlight.xls
    13.5 KB · Views: 740

HaHoBe

Locomotive Breath
Local time
Today, 19:21
Joined
Mar 1, 2002
Messages
233
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

  • Highlight re.xls
    27.5 KB · Views: 679

KirkComer

Registered User.
Local time
Today, 13:21
Joined
Oct 21, 2005
Messages
50
Thank you soooo much!!! :)
 

Users who are viewing this thread

Top Bottom