The original code seen above was written and works fine in Excel 2007 and up I believe, but I had trouble with the code on an older version at work running Excel 2003. I had to change the code to the following in order for it to give me the same results. This is just an update and a reference for anyone who might be looking for something similar.
' Add Highlight every other row
Dim lngCounter As Long
For lngCounter = 1 To Selection.Rows.Count
Select Case lngCounter Mod 2
Case 0
Selection.Rows(lngCounter).Interior.Color = RGB(155, 204, 255)
Case 1
Selection.Rows(lngCounter).Interior.Color = RGB(0, 255, 0)
End Select
Next lngCounter
' Add Borders
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With
End Sub
Bookmarks