View Single Post
 
Old 03-22-2021, 07:27 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Nancy,


I think Andrew had a slight glitch in his msgbox string. Try:
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 + vbCr _
   & x & " Columns." & vbCr + vbCr & sOthers
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote