View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_5_] Jim Thomlinson[_5_] is offline
external usenet poster
 
Posts: 486
Default macro total for colums with changing # of rows

Try this... It Adds the column total at the bottom of the columns you specify
(A and B in this case).

Sub Test()
ColumnTotal "A"
ColumnTotal "B"
End Sub

Sub ColumnTotal(ByVal strColumn As String)
Cells(Rows.Count, strColumn).End(xlUp).Offset(1, 0).Value = _
Application.Sum(Columns(strColumn))
End Sub

--
HTH...

Jim Thomlinson


"BillyRogers" wrote:

I'd like to build a macro that sums up four colums in a worksheet. The
workbook is generated automatically by a database program. Once I open the
workbook i have a macro that does all the formatting for me, but i have to go
in and manually totall the last four collums of the sheet.

These columns don't move they are the same in every sheet.
The number of rows varies from one report to the next.
The cells are all continous- in a rectangle shape-no empty cell inside the
report area.

i need some code that can sum the columns even thought the number or rows is
not constant each time i run the macro.

Any help is greatly apprecieated.

Billy