The following should work
Sub SortTables() 'Graham Mayor - https://www.gmayor.com - Last updated - 23 Jun 2021 Dim oTable As Table Dim oRng As Range Dim i As Integer Set oRng = ActiveDocument.Range oRng.Select Selection.Sort ExcludeHeader:=False, _ FieldNumber:="Paragraphs", _ SortFieldType:=wdSortFieldAlphanumeric, _ SortOrder:=wdSortOrderAscending Set oTable = ActiveDocument.Tables(1) Set oRng = oTable.Range With oRng.Find .Text = "^p" .Replacement.Text = "" .Execute Replace:=wdReplaceAll End With For i = oTable.Rows.Count - 1 To 2 Step -2 oTable.Rows(i).Select Selection.SplitTable Next i Set oTable = Nothing Set oRng = Nothing End Sub





Reply With Quote