PDA

View Full Version : I have a dynamic SUM function problem



j.smith1981
02-23-2010, 07:42 AM
I am wanting to write the last bit of a macro.

The problem is, its a web download of a report I have created in PHP.

What I want to do, is SUM up say column 1 2 and 3 yea?

But those columns could be from say 20-700 long, depends entirely on how many orders and products have been ordered that day.

Is there anyway of doing this, like the totals are all at the bottom of the page not at the sides at all, so we wouldnt be going across, its like so:

oder | product price
order1 | product1 | 10
order2 | product 2 | 10
Total Price 20 -- this would be the formula but could be furtherdown or infact further up, depending on orders and products placed

tpoynton
02-23-2010, 08:30 AM
Public Sub sumPrice()
Dim iRows As Integer
With ActiveSheet
iRows = .UsedRange.Rows.Count
.Cells(iRows + 1, 3).Value = WorksheetFunction.Sum(.Range(.Cells(2, 3), .Cells(iRows, 3)))
End With
End Sub

if this doesnt do as you wish, provide a sample workbook to better illustrate