Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA
Conditional formatting in a table based on cell content with a mac
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Gene-Salkovsky, post: 5869263"] I have a table that is 8 columns across and multiple rows. The 2nd row is my conditional. If it is filled with "X" or "x" it will fomat the last 5 columns of that row in a dark gray background. If it is Blank, it will not do anything. This needs to start on the first row and run until the end of the document. I have been able to create the macro that turns the last 5 columns gray (With my cursor in the 2nd cell) . This will work for doing this one row at a time, but I would prefer to do this all at once by clicking in row 1 / cell 2. I found something else with FOR/NEXT, but not able to get it to work. This, in theory, is what I am looking for below. [code] Sub Macro3() Dim TargetText As String Dim oRow As Row If Selection.Information(wdWithInTable) = False Then Exit Sub TargetText = Chr(88) Or Chr(120) For Each oRow In Selection.Tables(1).Rows If oRow.Cells(2).Range.Text = TargetText & vbCr & Chr(7) Then Selection.MoveRight Unit:=wdCharacter, Count:=8, Extend:=wdExtend Selection.Shading.Texture = wdTextureNone Selection.Shading.ForegroundPatternColor = wdColorAutomatic Selection.Shading.BackgroundPatternColor = wdColorGray15 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend Selection.Shading.Texture = wdTextureNone Selection.Shading.ForegroundPatternColor = wdColorAutomatic Selection.Shading.BackgroundPatternColor = wdColorAutomatic Selection.MoveLeft Unit:=wdCharacter, Count:=1 Next oRow End Sub [/code] Thank you. Gene [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA
Conditional formatting in a table based on cell content with a mac
Top