Conditional Formatting in a table on MS Word

Anonymous
2022-06-08T17:01:57+00:00

Hi,

I am trying to use conditional formatting in a table in MS Word. The table is a risk assessment. In 2 different columns I used developer to create drop downs values for the two categories, severity and frequency. The text selection for each column (ie: likely, possible, highly unlikely, etc) is paired with a value ranging from 1-5. In the last column to the right of the two categorical columns is the impact index. This is where I need the impact index value to populate with the right color and text for risk outcome (see the chart below for reference). How do I code the index value so that the color coordinates with outcome of the multiplicative of severity and frequency and it the cell autopopulates with the right text value (low, high, moderate, etc).

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Anonymous
    2022-06-08T19:11:37+00:00

    Hello,

    This forum is a user-to-user support forum. My name is Charles and I am a fellow user with decades of experience using Microsoft Word. I have written extensively on using Word and have authored help articles on the Microsoft site.

    Let me start by saying that such formatting is far easier in Excel. The simplest method is going to be to insert an Excel part for your table. Word is not really designed to handle conditional formatting.

    In Word conditional formatting encompasses having multiple sets of your result in an IF field where which one is displayed depends on the test in the IF field.
    Here is Microsoft's documentation on the IF field.
    https://support.microsoft.com/office/9f79e82f-e...
    Here is my writing on that field:
    https://www.addbalance.com/usersguide/fields.ht...

    Look at the part on "conditionally format table cells" in this tutorial by MVP Paul Edstein (macropod).
    https://www.msofficeforums.com/mail-merge/21803...

    See his responses here:
    https://www.msofficeforums.com/word-vba/16505-c...

    See the following questions and responses on this forum:


    These are links to pages on one or more pages on my website and on one or more sites that I personally trust and vouch for. Those pages contain accurate safe information that I think will help you. However, as an Independent Advisor I am required to give the following notice when providing non-Microsoft links, even to my own site :


    Required Notice: These are non-Microsoft websites. The pages appear to be providing accurate, safe information. Watch out for ads on the a that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.


    I hope this information helps.

    Please let me know if you have any more questions or require further help.

    You can ask for more help by replying to this post (Reply button below).

    Stay well

    6 people found this answer helpful.
    0 comments No comments
  2. Doug Robbins - MVP - Office Apps and Services 322K Reputation points MVP Volunteer Moderator
    2022-06-08T19:36:29+00:00

    The macro shown below is used to process a series of tables in a document so that cells are shaded depending upon the values assigned to each one, such as that shown below

    Sub ColorizeAll()

    timestart = Now

    On Error GoTo ExitThis

    With ActiveDocument

    For t = 2 To .Tables.Count Step 2 
    
        With .Tables(t) 
    
            For i = 1 To .Rows.Count - 1 
    
                If Len(.Cell(i, 1).Range.Text) > 2 Then 
    
                    j = i 
    
                Else 
    
                    Exit For 
    
                End If 
    
            Next i 
    
            For i = 1 To j 
    
                With .Rows(i) 
    
                    .Cells(4).Range.Fields.Update 
    
                    .Cells(7).Range.Fields.Update 
    
                    For k = 2 To 7 
    
                        Set crange = .Cells(k).Range 
    
                        crange.End = crange.End - 1 
    
                        Select Case Val(crange.Text) 
    
                            Case 1 To 4 
    
                                crange.Cells(1).Shading.BackgroundPatternColor = RGB(153, 204, 0) 
    
                            Case 5 To 12 
    
                                crange.Cells(1).Shading.BackgroundPatternColor = RGB(255, 153, 0) 
    
                            Case Is > 12 
    
                                crange.Cells(1).Shading.BackgroundPatternColor = RGB(255, 80, 80) 
    
                            Case Else 
    
                                If Len(crange.Text) < 5 Then 
    
                                    crange.Cells(1).Shading.BackgroundPatternColor = RGB(255, 255, 255) 
    
                                End If 
    
                        End Select 
    
                    Next k 
    
                End With 
    
            Next i 
    
        End With 
    
    Next t 
    

    End With

    timeend = Now

    elapsedtime = DateDiff("s", timestart, timeend)

    'MsgBox "Elapsed Time - " & elapsedtime & " seconds."

    ExitThis:

    End Sub

    3 people found this answer helpful.
    0 comments No comments
  3. Paul Edstein 82,806 Reputation points Volunteer Moderator
    2022-06-08T22:35:18+00:00
    2 people found this answer helpful.
    0 comments No comments