Hi there, I am very new to the use of Macros and VBA. I have a requirement to highlight alternate rows of a spread sheet (excel2003) with grey shading.
I am using this macro provided by MS support (http://support.microsoft.com/kb/213616):
Sub ShadeEveryOtherRow()
Dim Counter As Integer
'For every row in the current selection...
For Counter = 1 To Selection.Rows.Count
'If the row is an odd number (within the selection)...
If Counter Mod 2 = 1 Then
'Set the pattern to xlGray16.
Selection.Rows(Counter).Interior.Pattern = xlGray16
End If
Next
End Sub
- which does exactly what I want - except I don't like the "xlgray16"shading as the contrast makes it hard to distinguish the contents of the cells.
I much prefer the shading per
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
-this is what what was recorded when I did a simple "record macro".
My problem is I don't know how to incorporate the above pattern into the shading macro.
Can you help please? Many thanks in advance.
I am using this macro provided by MS support (http://support.microsoft.com/kb/213616):
Sub ShadeEveryOtherRow()
Dim Counter As Integer
'For every row in the current selection...
For Counter = 1 To Selection.Rows.Count
'If the row is an odd number (within the selection)...
If Counter Mod 2 = 1 Then
'Set the pattern to xlGray16.
Selection.Rows(Counter).Interior.Pattern = xlGray16
End If
Next
End Sub
- which does exactly what I want - except I don't like the "xlgray16"shading as the contrast makes it hard to distinguish the contents of the cells.
I much prefer the shading per
.ColorIndex = 15
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
-this is what what was recorded when I did a simple "record macro".
My problem is I don't know how to incorporate the above pattern into the shading macro.
Can you help please? Many thanks in advance.