#1
|
|||
|
|||
VBA to conditionally format table
Hi
I am trying to create a code which will format a specific cell in a table in Word, based on a cell in excel. I have a formatted table with text. I would like to reformat 1 cell in each row that matches the text in an excel cell. i have already opened the excel file in an earlier code and have the cells named. any help would be much appreciated. |
#2
|
|||
|
|||
To start you need to post your code.
|
#3
|
|||
|
|||
Hi Greg, sorry for the delay in replying.
I have put together this code which is working for a stored 'Score', however i want to be able to assign 6 word values to 'Score' and then for each row(j) change the value of 'Score'. Where i am stuck is can i store the values for example as numbers and then have For each J, Score = Score +1, or something like that? Code:
'Loop to select each row in the current table For J = 3 To NumRows 'Score reference has to change here for each J 'Loop to select each cell in the current row For K = 2 To (NumCols - 2) 'Select the cell to check Selection.Tables(1).Rows(J).Cells(K).Select 'Copy any text in the cell ChkTxt = Selection.Text ChkTxt = Left(ChkTxt, Len(ChkTxt) - 2) 'Check if text matches cell If (ChkTxt <> Score) Then Selection.Shading.BackgroundPatternColor = -570363137 'very light grey If (ChkTxt <> Score) Then Selection.Font.Bold = False If (ChkTxt <> Score) Then Selection.Font.ColorIndex = wdGray25 ' text grey Next K Next J |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Importing Data from Excel - Format of table messed up in Word Table | epsulliv | Word Tables | 6 | 08-24-2015 07:29 AM |
Format Painter doesn't work on Table Format? | Joey Cheung | Word Tables | 1 | 08-20-2014 02:24 AM |
1.image in a table 2.right click 3.menu click format 4.a format column appears | OldFatDog | Drawing and Graphics | 1 | 06-13-2014 11:19 PM |
How to conditionally format cells in Col. A if it matches adjacent cell in Col. B? | alshcover | Excel | 2 | 06-03-2014 12:50 PM |
How to conditionally format this? | g4tv4life | Excel | 2 | 03-13-2014 10:58 AM |