![]() |
|
|
|
#1
|
||||
|
||||
|
If you have already marked the cells contents as bold and red or green then the following will shade the cells, although the colour you quoted is in fact a pale green?
Code:
Sub Macro1()
Dim oTable As Table
Dim oCell As Cell
For Each oTable In ActiveDocument.Tables
For Each oCell In oTable.Range.Cells
If oCell.Range.Font.Bold = True Then
If oCell.Range.Font.ColorIndex = wdRed Or _
oCell.Range.Font.ColorIndex = wdGreen Then
oCell.Shading.BackgroundPatternColor = -654246093
End If
End If
Next oCell
Next oTable
Set oTable = Nothing
Set oCell = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#2
|
||||
|
||||
|
Hello, Graham,
I've tested it and it produce no color. The fact that you see the color code green versus orange, it depends on the Office Theme. By default, my Word document has the 2007-2010 office theme. I didn't mind to have the green or orange color, but neither worked. In my initial request, I was hoping to add the valued searched for, to be Highlighted + if possible, to have the ''Text'' to do the search. Would that change to do the Find and Replace code? I'm doing manually for now, but hopefully when I get a big documents, to not have to do it manually. Thanks for trying though
|
|
| Tags |
| macro help, shade a cell, word table macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Conditionally Shade Table Cells
|
S7ewie | Mail Merge | 8 | 04-29-2021 01:52 AM |
| Macro to change an RGB table cell shading color to another RGB color | David Matthews | Word VBA | 4 | 05-29-2018 02:45 PM |
Code to find a named (bookmarked?) table, replicate a row or table, and delete a specified table.
|
kevinbradley57 | Word VBA | 9 | 09-21-2017 04:58 PM |
Text area in table won't shade
|
LSHAW | Word Tables | 1 | 03-09-2017 03:08 PM |
VBA Table – Search All Tables - Find & Replace Text in Table Cell With Specific Background Color
|
jc491 | Word VBA | 8 | 09-30-2015 06:10 AM |