ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sum up an unknown number of rows (https://www.excelbanter.com/excel-programming/355783-sum-up-unknown-number-rows.html)

skoller

sum up an unknown number of rows
 

Hello. I think it's simple problem but as newbee in VBA it's a big one
for me.

First an example how my table could look like:
(I used simple numbers for the example, nomally these numbers are
calculated with several fomulars)

SET1
20
40
20
SUM: 80

SET2
20
30
SUM: 50

SET3
30
SUM: 30


The sum of every set should be calculated automatically with a
formular. Not a big deal but the problem is the following:
You can add new numbers in every Set with a makro. Therefore I don't
know how many rows I have to use to calculate the sum.
I need a script which sums all the rows between the beginning and the
end of every single set. The calculation of the sum should also work,
if you delete one row or number.

Thank you for any help in advance.

cheers
Stefan


--
skoller
------------------------------------------------------------------------
skoller's Profile: http://www.excelforum.com/member.php...o&userid=32388
View this thread: http://www.excelforum.com/showthread...hreadid=521522


Bob Phillips[_6_]

sum up an unknown number of rows
 

n=0
For i = 1 to Cells(Rows.Count,"A").End(xlUp).Row
If Cells(i,"A").Value = "" Then
Cells(i,"A").Value = n
Else
If Left(Cells(i,"A").Value,3) < "SET" Then
n = n + Cells(i,"A").Value
End If
End If
Next i

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"skoller" wrote in
message ...

Hello. I think it's simple problem but as newbee in VBA it's a big one
for me.

First an example how my table could look like:
(I used simple numbers for the example, nomally these numbers are
calculated with several fomulars)

SET1
20
40
20
SUM: 80

SET2
20
30
SUM: 50

SET3
30
SUM: 30


The sum of every set should be calculated automatically with a
formular. Not a big deal but the problem is the following:
You can add new numbers in every Set with a makro. Therefore I don't
know how many rows I have to use to calculate the sum.
I need a script which sums all the rows between the beginning and the
end of every single set. The calculation of the sum should also work,
if you delete one row or number.

Thank you for any help in advance.

cheers
Stefan


--
skoller
------------------------------------------------------------------------
skoller's Profile:

http://www.excelforum.com/member.php...o&userid=32388
View this thread: http://www.excelforum.com/showthread...hreadid=521522




skoller[_2_]

sum up an unknown number of rows
 

Thank you for the quick reply.:)


--
skoller
------------------------------------------------------------------------
skoller's Profile: http://www.excelforum.com/member.php...o&userid=32388
View this thread: http://www.excelforum.com/showthread...hreadid=521522



All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com