Change cell shading of selected table

A

andreas

Dear Experts:

I would like to have below macro altered to achieve the following in a
table with several different shadings of different colours:

- the RGB values (Red, Blue, Green) is to be taken from the currently
selected cell and then
- ... inserted into the <SelectedCellShading> part of below macro

Is this feasible?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub Change_Shading_SelectedTable()

Dim oTable As Table
Dim aCell As Cell

Set oTable = Selection.Tables(1)
With oTable
For Each aCell In oTable.Range.Cells
If aCell.Shading.BackgroundPatternColor =
<SelectedCellShading> Then
aCell.Shading.BackgroundPatternColor = RGB(222, 222, 222)
End If
Next aCell
End With

End Sub
 
G

Graham Mayor

Sub Change_Shading_SelectedTable()

Dim oTable As Table
Dim aCell As Cell
Dim sShading As String
sShading = Selection.Shading.BackgroundPatternColor
Set oTable = Selection.Tables(1)
With oTable
For Each aCell In oTable.Range.Cells
If aCell.Shading.BackgroundPatternColor = _
sShading Then
aCell.Shading.BackgroundPatternColor = RGB(222, 222, 222)
End If
Next aCell
End With
End Sub


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


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

andreas

Sub Change_Shading_SelectedTable()

Dim oTable As Table
Dim aCell As Cell
Dim sShading As String
sShading = Selection.Shading.BackgroundPatternColor
Set oTable = Selection.Tables(1)
With oTable
    For Each aCell In oTable.Range.Cells
        If aCell.Shading.BackgroundPatternColor = _
        sShading Then
            aCell.Shading.BackgroundPatternColor = RGB(222,222, 222)
        End If
    Next aCell
End With
End Sub

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

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















- Zitierten Text anzeigen -

Hey Graham,

ok, great, Thank you for your swift and professional help.

Regards, 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