ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro sum (https://www.excelbanter.com/excel-discussion-misc-queries/245775-macro-sum.html)

puiuluipui

Macro sum
 
Hi, i need a macro to sum every nea range and display result to the next cell
in the last row in colum "L".
Ex:
L M
total sum
15
2
8 25
total
7
7
5 19
I need a macro to sum only range that doesn't have a sum at the last
row/next cell.
I need macro to sum below total and to add sum. the problem is that i
allways add entries, so it will not be a range, so i need to sum the last
entries below total.
Can this be done?
Thanks!

Don Guillett

Macro sum
 

Sub getsubtotalsSAS()
mc = "L"
lr = Cells(Rows.Count, mc).End(xlUp).Row + 1
For i = 2 To lr
If IsNumeric(Cells(i, mc)) Then msum = msum + Cells(i, mc)
If LCase(Cells(i, mc)) = "total" Or Cells(i, mc) = "" Then
Cells(i, mc).Offset(-1, 1) = msum
msum = 0
End If
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"puiuluipui" wrote in message
...
Hi, i need a macro to sum every nea range and display result to the next
cell
in the last row in colum "L".
Ex:
L M
total sum
15
2
8 25
total
7
7
5 19
I need a macro to sum only range that doesn't have a sum at the last
row/next cell.
I need macro to sum below total and to add sum. the problem is that i
allways add entries, so it will not be a range, so i need to sum the last
entries below total.
Can this be done?
Thanks!




All times are GMT +1. The time now is 12:38 PM.

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