Found a solution.
See below.
Hope someone finds this useful.
This sums the values in column 3, and puts the result into a bookmark,
"Total".
------------------------------------------
Sub GerryTable()
'
' GerryTable Macro
' Macro recorded 09/11/03 by Gerry
Dim myTable As Table
Dim nTotal As Double
Dim i As Integer
Set myTable = ActiveDocument.Tables(2)
With myTable
For i = 2 To .Rows.Count
nTotal = nTotal + celValue(myTable, i, 3)
Next i
End With
Set myTable = Nothing
With myTable
ActiveDocument.Bookmarks.Item("total").Range.Text = Int(nTotal * 100 +
0.5) / 100
End With
Debug.Print nTotal
End Sub
Function celValue(mTable As Table, mRow As Integer, mCol As Integer) As
Double
With mTable
celValue = Val(Left(.Cell(mRow, mCol).Range.Text, Len(.Cell(mRow,
mCol).Range.Text) - 2))
End With
End Function
----------------------------------------
Gerry Abbott said:
Hi all again,
Think I have an approach but need help.
I intend to get the number of rows from the table object,
Then for the required column, iteratively sum the cell contents.
However i'm running into difficulty in returning the contents of the cell,
then converting to numeric.
How can i return the contents of the cell rather than the cell reference.?
Any advice welcome.
------------------------------
Sub GerryTable()
'
' GerryTable Macro
' Macro recorded 09/11/03 by Gerry
'
Dim myTable As Table
Dim myVar As Variant
Dim nRows as integer
Dim nCols as Integer
Set myTable = ActiveDocument.Tables(1)
With myTable
nRows = .Rows.Count
nCols= .Columns.Count
myVar = .Rows(i).Cells(2)
End With
end sub