The issue with your table is that because some of the lines don't have a tab character, only the first column is filled, so when you merge the columns, the empty cells are moved up. You need to ensure that there is something in the second cell for this to work e.g.
Sub Macro1() Dim oCell As Cell Dim oRng As Range ActiveDocument.Range.ConvertToTable _ Separator:=wdSeparateByTabs, _ NumColumns:=2 With ActiveDocument.Tables(1) .Style = "Table Grid" .ApplyStyleHeadingRows = True .ApplyStyleFirstColumn = True For Each oCell In .Columns(2).Cells If Len(oCell.Range) = 2 Then Set oRng = oCell.Range oRng.End = oRng.End - 1 oRng.Text = "-" End If Next oCell With .Columns(1) .Cells.Merge .AutoFit End With With .Columns(2) .Cells.Merge .AutoFit End With End With lbl_Exit: Set oCell = Nothing Set oRng = Nothing Exit Sub End Sub




Reply With Quote
