View Single Post
 
Old 10-27-2020, 03:53 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I suspect the runtime error is coming from vertically merged cells rather than multiple instances of Tree Number. Can you confirm that your tables have no vertically merged cells?

To continue working on the same table, this change to Paul's code appears to work
Code:
Sub SplitTables()
  Application.ScreenUpdating = False
  Dim t As Long, c As Long
  With ActiveDocument
    On Error Resume Next
    For t = .Tables.Count To 1 Step -1
RestartTable:
      With .Tables(t).Range
        For c = .Cells.Count To 1 Step -1
          With .Cells(c)
            If .RowIndex > 1 Then
              If Split(.Range.Text, vbCr)(0) = "Tree Number" Then
                .Range.InsertBreak (wdColumnBreak)
                GoTo RestartTable
              End If
            End If
          End With
        Next
      End With
    Next
  End With
  Application.ScreenUpdating = True
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote