View Single Post
 
Old 03-21-2021, 08:18 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

I haven't done rigorous testing but this should get you started
Code:
Sub TestTables()
  Dim i As Integer, x As Integer, iTbl As Integer, sOthers As String
  For i = 1 To ActiveDocument.Tables.Count
    If ActiveDocument.Tables(i).Columns.Count > x Then
      x = ActiveDocument.Tables(i).Columns.Count
      iTbl = i
      sOthers = ""
    ElseIf ActiveDocument.Tables(i).Columns.Count = x Then
      sOthers = sOthers & i & ", "
    End If
  Next i
  If sOthers <> "" Then sOthers = "Other tables with same column count are: " & sOthers
  MsgBox "The table with the most columns is " & iTbl & vbCr & sOthers, , x & " Columns"
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote