View Single Post
 
Old 04-09-2019, 03:43 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

Try this version
Code:
Sub Results2()
  Dim i As Integer, iTables As Integer
  Dim aTbl As Table, tblLast As Table
  Dim aRng As Range, aRngEnd As Range
  
  iTables = ActiveDocument.Tables.Count
  Set tblLast = ActiveDocument.Tables(iTables)
  
  For i = 1 To iTables - 1
    Set aTbl = ActiveDocument.Tables(i)
    Set aRng = aTbl.Range.Cells(1).Range
    If InStr(aRng.Text, "Worksheet") > 0 Then
      Set aRngEnd = tblLast.Range
      aRngEnd.Collapse Direction:=wdCollapseEnd
      aRngEnd.FormattedText = aTbl.Rows.Last.Range.FormattedText
    End If
  Next i
End Sub
Note that you will likely encounter problems if your tables have merged cells or the cell counts are not consistent in the last rows.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote