Word Macro to search all tables
Hello
I have four (4) tables in word, each with 9 columns with varying rows. In all instances the last row, column holds a field that sums values above it. I would like to have a macro that searches the last column and resets the values to zero (0) except for the last row. I've tried creating said macro, however it only runs if the cursor is positioned in a table and the macro runs within that table, I can't get the macro to programmatically move to the next table using the table index:
Dim C As Cell
Dim LastCell As Long
Dim i As Long
i = 1
For i = 1 To 4
Set tbl = ActiveDocument.Tables(i)
LastCell = ActiveDocument.Tables(i).Rows.Count - 1
Selection.SetRange _
Start:=Selection.Tables(i).Cell(2, 9).Range.Start, _
End:=Selection.Tables(i).Cell(LastCell, 9).Range.End
With Selection
For Each C In Selection.Cells
C.Range.Text = "0"
Next C
End With
Next i
Your help is appreciated, thx
|