Forum Discussion
a_bonsey
May 16, 2022Brass Contributor
vba table valid row count
Hi, I'm supplied Word documents that contain a table that has differing valid rows therefore I need a variable to count the valid rows. In Excel this would be something like: Sub Test()
Wi...
a_bonsey That document contains a Word table, not an Excel worksheet.
The following macro will tell you how many rows contain data:
With ActiveDocument.Tables(1)
For i = 1 To .Rows.Count
If Len(.Cell(i, 1).Range) < 3 Then
Exit For
End If
Next i
End With
MsgBox "The table contains data in " & i - 1 & " rows, including the header row."
a_bonsey
May 18, 2022Brass Contributor
That worked brilliantly and looked so obvious when you laid it out like that.
Just couldn't see the woods for the trees as they say!!
Thanks again