Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-05-2019, 08:59 AM
lmoir87 lmoir87 is offline VBA to conditionally format table Windows 7 64bit VBA to conditionally format table Office 2010 64bit
Novice
VBA to conditionally format table
 
Join Date: Jul 2014
Posts: 7
lmoir87 is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 08-05-2019, 10:31 AM
gmaxey gmaxey is offline VBA to conditionally format table Windows 10 VBA to conditionally format table Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

To start you need to post your code.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 08-23-2019, 03:42 AM
lmoir87 lmoir87 is offline VBA to conditionally format table Windows 7 64bit VBA to conditionally format table Office 2010 64bit
Novice
VBA to conditionally format table
 
Join Date: Jul 2014
Posts: 7
lmoir87 is on a distinguished road
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to conditionally format table Importing Data from Excel - Format of table messed up in Word Table epsulliv Word Tables 6 08-24-2015 07:29 AM
VBA to conditionally format table Format Painter doesn't work on Table Format? Joey Cheung Word Tables 1 08-20-2014 02:24 AM
VBA to conditionally format table 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
VBA to conditionally format table 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
VBA to conditionally format table How to conditionally format this? g4tv4life Excel 2 03-13-2014 10:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft