Slicemahn
01-16-2015, 01:51 PM
Using Excel 2007
Hey Everyone,
I need a second pair of eyes to help me find out what is wrong with my code to highlight a row based upon a populated cell.
Essentially what I am doing is looping through the data to find the cell in which is populated (Column U) and then from that cell go down to the next free or non-populated cell and then highlight that entire row (similar to xlDown.Row action).
Here is my code....
Sub HighlightIt()
Dim EndRow As Long
Dim RowStepper As Integer
Dim SummaryRow As Integer
Dim ws As Worksheet
Application.ScreenUpdating = False
Set ws = Sheets("LearningPlanItems")
With ws
EndRow = .Cells(65536, 1).End(xlUp).Row
EndRow = EndRow - 1
For RowStepper = EndRow To 5 Step -1
If ws.Cells(RowStepper, 21).Value Is Not Null Then
SummaryRow = ws.Cells(RowStepper, 21).End(xlDown).Row
ws.Rows(SummaryRow).EntireRow.Interior.ColorIndex = 28
End If
SummaryRow = 0
Next RowStepper
Application.ScreenUpdating = True
End With
End Sub
I get an object error each time I try to execute this code.
Thanks.
Hey Everyone,
I need a second pair of eyes to help me find out what is wrong with my code to highlight a row based upon a populated cell.
Essentially what I am doing is looping through the data to find the cell in which is populated (Column U) and then from that cell go down to the next free or non-populated cell and then highlight that entire row (similar to xlDown.Row action).
Here is my code....
Sub HighlightIt()
Dim EndRow As Long
Dim RowStepper As Integer
Dim SummaryRow As Integer
Dim ws As Worksheet
Application.ScreenUpdating = False
Set ws = Sheets("LearningPlanItems")
With ws
EndRow = .Cells(65536, 1).End(xlUp).Row
EndRow = EndRow - 1
For RowStepper = EndRow To 5 Step -1
If ws.Cells(RowStepper, 21).Value Is Not Null Then
SummaryRow = ws.Cells(RowStepper, 21).End(xlDown).Row
ws.Rows(SummaryRow).EntireRow.Interior.ColorIndex = 28
End If
SummaryRow = 0
Next RowStepper
Application.ScreenUpdating = True
End With
End Sub
I get an object error each time I try to execute this code.
Thanks.