Totaling Columns

J

jimbo

I have a document that i am in the process of formatting, however i
need to total up columns of data. I know where the bottom on the data
will be and can activate the cell either at the last column with data
or the column below this. this action is then repeated within my loop.

Can anyone help??
 
D

Dave Lett

Hi Jimbo,

The following should get your well on your way:

Dim oTbl As Table
Dim lRow As Long
Dim lCount As Long
Set oTbl = ActiveDocument.Tables(1)
lRow = oTbl.Rows.Count
For lCount = 1 To oTbl.Columns.Count
With oTbl
Set oRng = .Columns(lCount).Cells(lRow).Range
oRng.MoveEnd Unit:=wdCharacter, Count:=-1
oRng.Select
Selection.InsertFormula Formula:="=Sum(ABOVE)"
End With
Next lCount

HTH,
Dave
 
Top