Question posted 2011 · +6 upvotes
I spent a VERY long time today looking up a method to alternate row colors within a specified range. There really isn’t a lot out there and to be honest what I found just looked over-complicated. So, I decided to stop acting like a shameless ‘script-kiddy’ and put the below sample together:
Sub AlternateRowColors()
Dim lastRow as Long
lastRow = Range("A1").End(xlDown).Row
For Each Cell In Range("A1:A" & lastRow) ''change range accordingly
If Cell.Row Mod 2 = 1 Then ''highlights row 2,4,6 etc|= 0 highlights 1,3,5
Cell.Interior.ColorIndex = 15 ''color to preference
Else
Cell.Interior.ColorIndex = xlNone ''color to preference or remove
End If
Next Cell
End Sub
Now I know that works, but I was wondering if there’s a simpler method?
If so, please do tell because I’m very eager to learn simplification as I have a tendency to write verbose code at present. If not, then may this entry find it’s way to page 1 of Google for it’s search term(s), because it took me absolutely ages to find anything even remotely useful.
Comments left for script-kiddies’ benefit.
The following lines of code may be removed if your data contains no pre-exisiting colors:
Else
Cell.Interior.ColorIndex = xlNone
Accepted answer +7 upvotes
Alternating row colors can be done using conditional formatting:

Top excel-vba Q&A (6)
- How to clear the entire array? +58 (2010)
- How to change Format of a Cell to Text using VBA +55 (2011)
- Download attachment from Outlook and Open in Excel +43 (2012)
- Can a VBA function in Excel return a range? +36 (2009)
- 2 Dimensional array from range +34 (2013)
- Hiding an Excel worksheet with VBA +33 (2009)
excel-vba solutions on this site
.