View Single Post
 
Old 09-30-2015, 02:16 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

The simplest approach would be to test whether the rows preceding the 'Ensure SXXXXX' content have more than one cell and, if not, skip over them, this:
Code:
Sub Demo()
Dim i As Long, StrTxt As String
With ActiveDocument.Tables(1)
  For i = .Rows.Count To 2 Step -1
    If .Rows(i - 1).Cells.Count > 1 Then
      If InStr(.Cell(i, 2).Range.Text, "Ensure S") = 1 Then
        StrTxt = Split(.Cell(i, 2).Range.Text, " ")(1)
        .Rows.Add BeforeRow:=.Rows(i)
        With .Rows(i)
          .Cells.Merge
          .Shading.BackgroundPatternColor = -603930625
          .Range.Style = wdStyleNormal
          .Range.Text = "Step " & StrTxt
        End With
      End If
    Else
      i = i - 1
    End If
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote