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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top