jimbojames136 Posted March 5, 2012 Posted March 5, 2012 Is it possible to highlight a row in a 4 column table, based on a value in the fourth column? thanks james
Jawloms Posted March 5, 2012 Posted March 5, 2012 Do you mean this? How To Highlight Rows Based on a Cell Value in Excel - Jon Gallant's Blog - Site Home - MSDN Blogs
jimbojames136 Posted March 5, 2012 Author Posted March 5, 2012 No i mean in Microsoft Word.... I have a table with 4 columns and i want to be able to colour a row based on the 4th column?
Pico Posted March 6, 2012 Posted March 6, 2012 I don't think you can do this in Word. If your values are changing, so that you want the formatting to update too, perhaps you could prepare your table in Excel and link the table to display it in Word?
enjay Posted March 6, 2012 Posted March 6, 2012 Conditional formatting in Excel will do this, but Word can't - does it have to be in Word?
jimbojames136 Posted March 6, 2012 Author Posted March 6, 2012 Yes, it is an individual report from SIMS so it has to be in word, as far as im aware! I got a VB script to look at the column that i want, and select it, but i do not know how to make it look at the data. One would have thought it would be an IF statement of some kind. But i am no VB Scripter and could be talking utter rubbish!!!
Jawloms Posted March 6, 2012 Posted March 6, 2012 If it's a report from SIMS, can't you change the output to Excel, or make your own version of it which goes to Excel?
jimbojames136 Posted March 6, 2012 Author Posted March 6, 2012 Not sure you can change the output of an Individual Report from SIMS. I know you can do this with Standard SIMS Reports......
CESIL Posted March 6, 2012 Posted March 6, 2012 Try this...it's Word 2003 but should work for later versions... Public Sub highlighter() Dim obj As Table Set obj = ActiveDocument.Tables(1) For x = 1 To obj.Rows.Count If Val(obj.Rows(x).Cells(7).Range.Text) < 3 Then obj.Rows(x).Shading.BackgroundPatternColor = wdColorGray20 End If Next End Sub
jimbojames136 Posted March 6, 2012 Author Posted March 6, 2012 That seems to Highlight the whole thing.... Attached is the table, i need it to automatically highlight a row that contains a Y in Concern column. I cannot do this in Excel as it is an Individual Report from SIMS and as far as im aware you cannot change the output of a Individual Report to Excel. Any help would be much appreciated. Table1.doc
CESIL Posted March 6, 2012 Posted March 6, 2012 You just needed to change the cell references and the value check to match your data... Try this Public Sub highlighter() Dim obj As Word.Table Dim x As Integer Set obj = ActiveDocument.Tables(1) For x = 1 To obj.Rows.Count If Left(obj.Rows(x).Cells(4).Range.Text, 1) = "Y" Then obj.Rows(x).Shading.BackgroundPatternColor = wdColorGray20 End If Next End Sub 1
jimbojames136 Posted March 6, 2012 Author Posted March 6, 2012 Thanks Cesil..... that worked. Really appreciate that!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now