J
Jane Pumroy
This macro works with Word versions using Word Visual
Basic. Note the cursor needs to be in the cell you wish
to place the total.
Sub SumColumn()
'
' SumColumn Macro
' Macro created 09/20/2004 by JAPUMROY
'
Dim Col As Integer
Dim Cell As Integer
Dim ColInfo
If Selection.Information(wdWithInTable) = False Then
MsgBox "The insertion point is not in a table."
End If
If Selection.Information(wdWithInTable) = True Then
Col = Selection.Cells(1).ColumnIndex
ColInfo = Chr(Col + 64)
End If
If Selection.Information(wdWithInTable) = True Then
Cell = Selection.Cells(1).RowIndex - 1
Set myRange = ActiveDocument.Words(1)
End If
myRange = "=SUM(" & ColInfo & "1:" & ColInfo & Cell
& ")"
Selection.InsertFormula Formula:=myRange,
NumberFormat:=""
End Sub
Basic. Note the cursor needs to be in the cell you wish
to place the total.
Sub SumColumn()
'
' SumColumn Macro
' Macro created 09/20/2004 by JAPUMROY
'
Dim Col As Integer
Dim Cell As Integer
Dim ColInfo
If Selection.Information(wdWithInTable) = False Then
MsgBox "The insertion point is not in a table."
End If
If Selection.Information(wdWithInTable) = True Then
Col = Selection.Cells(1).ColumnIndex
ColInfo = Chr(Col + 64)
End If
If Selection.Information(wdWithInTable) = True Then
Cell = Selection.Cells(1).RowIndex - 1
Set myRange = ActiveDocument.Words(1)
End If
myRange = "=SUM(" & ColInfo & "1:" & ColInfo & Cell
& ")"
Selection.InsertFormula Formula:=myRange,
NumberFormat:=""
End Sub