Apply alternate grey/red shading to selected rows in a table

A

andreas

Dear Experts:

With any number of rows SELECTED in a table I would like to apply
alternate (grey/red) shading.

Grey: RGB (242, 242, 242)
Red: RGB (239, 211, 210)

How can this be achieved using VBA?

Help is much appreciated.

Thank you very much in advance.

Regards, Andreas
 
G

Graham Mayor

You are not trying now ;)
This is almost the same as the question you asked earlier in the week


Dim i As Long
Dim oRow As Row
i = 1
For Each oRow In Selection.Range.Rows
If i Mod 2 = 0 Then
oRow.Shading.BackgroundPatternColor = RGB(242, 242, 242)
Else
oRow.Shading.BackgroundPatternColor = RGB(239, 211, 210)
End If
i = i + 1
Next


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

andreas

You are not trying now ;)
This is almost the same as the question you asked earlier in the week

Dim i As Long
Dim oRow As Row
i = 1
For Each oRow In Selection.Range.Rows
    If i Mod 2 = 0 Then
        oRow.Shading.BackgroundPatternColor = RGB(242, 242, 242)
    Else
        oRow.Shading.BackgroundPatternColor = RGB(239, 211, 210)
    End If
   i = i + 1
Next

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>












- Show quoted text -

Hi Graham,

thank you very much for your terrific help. It works as desired.

Graham, you are right, it is almost the same question as the one from
last week. The one from last week was about paragraph shading, this
one is about table shading.

Again, thank you very much for your superb help. I really appreciate
it. I turned to your website a couple of weeks ago for mail merge
advice including graphics. You saved my day with the tips.
Superb tutorial on this matter. The best I could find so far.

Regards from Germany, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top