Thread: [Solved] Adding new rows to a table
View Single Post
 
Old 04-07-2021, 04:50 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Whilst I agree with Andrew regarding the desirability of avoiding double rows, I think a macro can also be made to replicate the structure fairly reliably where such avoidance isn't practical. For example:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim RngSrc As Range, RngTgt As Range
With Selection
  If .Information(wdWithInTable) = False Then Exit Sub
  With .Tables(1)
    Set RngSrc = .Rows(.Rows.Count - 1).Range
    RngSrc.End = .Range.End
    Set RngTgt = .Range
    RngTgt.Collapse wdCollapseEnd
    RngTgt.FormattedText = RngSrc.FormattedText
    .Rows(.Rows.Count - 1).Range.Delete
    .Rows(.Rows.Count - 1).Cells(1).Range.Text = (.Rows.Count - 1) / 2
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote