View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Charles Charles is offline
external usenet poster
 
Posts: 1
Default VBA-Add Column Totals

Chris,

I hope the following helps. It assumes you want to total colunn a.
You can make changes to suit your needs.

Sub add_column()
Application.ScreenUpdating = False
Dim irng As Range
Dim firstcell, lastcell
Set irng = Worksheets("sheet2").Cells(1, 1).CurrentRegion
lastrow = Range("a1").End(xlDown).Select
firstcell = "A1"
lastcell = ActiveCell.Row
TheFormula = "=sum(" & firstcell & ":" & "A" & lastcell & ")"
ActiveCell.Offset(1, 0).Value = TheFormula
ActiveWindow.SelectedSheets.PrintPreview
Selection.Offset(1, 0).ClearContents
End Sub

Charle

--
Message posted from http://www.ExcelForum.com