Thread: VBA problems
View Single Post
  #1   Report Post  
Andrew Clark
 
Posts: n/a
Default VBA problems

Hello,

I just started messing around with VBA and I got something approaching
what I want (what I want is to highlight a row based on a value in the
1st column). This is highlighting the wrong row though! It looks like all
the numbers are correct... for instance, when I step through it, I'll get
the correct row selected but a different row highlighted! Please shed
some light on this! It's quite frustrating.

' first column has dates from 12/2003 to 12/2006
Private Sub Worksheet_Activate()
Const Yellow = 6
Dim row As String
Range("A1").Select
Do While ActiveCell.Value < ""
Selection.EntireRow.Interior.ColorIndex = xlColorIndexNone
If Month(ActiveCell.Value) = Month(Now) And _
Year(ActiveCell.Value) = Year(Now) Then
row = "A" & CStr(ActiveCell.row) & _
":L" & CStr(ActiveCell.row)
'MsgBox (row)
Selection.Range(row).Interior.ColorIndex = Yellow
Exit Sub
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub



Thanks,
Andrew