Thread: [Solved] Table formatting issue:
View Single Post
 
Old 05-02-2025, 04:09 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

Try:
Code:
Sub CellMerge()
Application.ScreenUpdating = False
Dim Tbl As Table, Cll As Cell
For Each Tbl In ActiveDocument.Tables
  For Each Cll In Tbl.Range.Cells
    With Cll
      If .ColumnIndex < Tbl.Columns.Count Then
        If .Borders(wdBorderBottom).LineStyle = wdLineStyleNone And _
          .Borders(wdBorderTop).LineStyle = wdLineStyleNone Then
          .Merge MergeTo:=Tbl.Cell(Row:=.RowIndex + 1, Column:=.ColumnIndex)
          .Merge MergeTo:=Tbl.Cell(Row:=.RowIndex - 1, Column:=.ColumnIndex)
        End If
      End If
    End With
  Next
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote