![]() |
#12
|
||||
|
||||
![]()
If your document could potentially have tables with horizontally-merged cells, uneven cell widths in a column, or vertically-split cells, you need something like:
Code:
Sub TestTables() Dim t As Long, c As Long, x As Long, y As Long, z As Long, StrTbls As String With ActiveDocument For t = 1 To .Tables.Count With .Tables(t) If .Uniform = True Then z = .Columns.Count If z = x Then StrTbls = StrTbls & ", " & t If z > x Then x = z: StrTbls = t Else z = 0 With .Range For c = 1 To .Cells.Count y = .Cells(c).ColumnIndex If y >= x Then z = y Next End With If z = x Then StrTbls = StrTbls & ", " & t If z > x Then x = z: StrTbls = t End If End With Next End With MsgBox "The most columns (" & x & ") are found in table(s): " & StrTbls End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
help please, most table column |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA to add final touches to merged document, after running MailMergeToDoc script | NicB | Word VBA | 1 | 09-02-2020 05:47 PM |
How to generate a word document with a table-script | valdavaux | Word | 1 | 09-17-2017 03:32 PM |
Is it possible to put a formula in a table column header to define the name of the column? | JacquesW | Excel | 3 | 05-08-2017 08:00 AM |
VBA to search each row of a word table column | Marrick13 | Word VBA | 7 | 11-17-2014 04:33 AM |
![]() |
plato | Word | 1 | 08-06-2010 04:02 AM |