Summing Columns With Blank Rows

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
 

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