PDA

View Full Version : Seriously Excel? Change Row Colors



Saladsamurai
09-04-2009, 07:16 AM
I am beginning to despise Excel more and more with each day.

I want to take a Worksheet and simply "highlight" every other row yellow.

My idea was to record a Macro and modify it. Here is the Recorded Macro:

Sub Macro1()
Rows("1:1").Select
With Selection.Interior
.ColorIndex = 19
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End Sub


And here is the Modification I made:
Sub Macro1()

For i = 2 to 100 Step 2

WorkSheets(1).Rows("i:i").Select
With Selection.Interior
.ColorIndex = 19
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With

Next i
End Sub


Why doesn't that work? It doesn't like the notation ("i:i") for some reason.

:motz2:

Ken Puls
09-04-2009, 01:50 PM
Try this:


Sub Macro1()
Dim i as Long

For i = 2 To 100 Step 2


With WorkSheets(1).Rows(i).Interior
.ColorIndex = 19
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With


Next i

End Sub