View Single Post
 
Old 08-01-2018, 03:08 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Word has nothing like Excel's COUNTIF function, but it isn't needed anyway. The code to implement the additional output is fairly straightforward.

First, define a new variable:
Code:
  Dim ArrRisks: ArrRisks = Array(" ", "Low", "Moderate", "Significant", "High")
Second, replace:
Code:
    If i = 1 Or j = 1 Then
      StrTxt = ""
    Else
      StrTxt = Split(Tbl.Cell(i + 1, j + 1).Range.Text, vbCr)(0)
    End If
with:
Code:
    If i = 1 Or j = 1 Then
      StrTxt = " "
    Else
      StrTxt = Split(Tbl.Cell(i + 1, j + 1).Range.Text, vbCr)(0)
    End If

    For i = 0 To UBound(ArrRisks)
      If ArrRisks(i) = StrTxt Then Exit For
    Next
    With ActiveDocument.SelectContentControlsByTitle("Highest Residual Risk")(1).Range
      For j = 0 To UBound(ArrRisks)
        If ArrRisks(j) = .Text Then Exit For
      Next
      If i > j Then .Text = StrTxt
    End With
Done.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote