fosterp
04-24-2008, 10:32 AM
Hi
I have a spreadhseet with lots of manual subtotals, probably about 30.
I've tried to figure out a macro using a loop to add all subtotals to rpoduce a total.
e.g. say subtotals are in a5, a8, a12 etc.
I could manually find all subtotals and do a massive =sum(a5,a8 etc. )
However, please could someone show me how to write a amcro to do this.
I have some code below. I just need someone to help me fill in the gaps.
Code
Sub suBtot()
Dim cell As Range
Dim r As Range
Dim s As Range
For Each cell In Range([a1], [a444])
If IsEmpty(cell) = False Then
Set r = cell.Offset(0, 4).End(xlDown) - where subtotals are.
'Summing cells ( subtotals )
cells(1,400).value = ' formula that would add up all subtotals.) i.e.
end if
next
I have a spreadhseet with lots of manual subtotals, probably about 30.
I've tried to figure out a macro using a loop to add all subtotals to rpoduce a total.
e.g. say subtotals are in a5, a8, a12 etc.
I could manually find all subtotals and do a massive =sum(a5,a8 etc. )
However, please could someone show me how to write a amcro to do this.
I have some code below. I just need someone to help me fill in the gaps.
Code
Sub suBtot()
Dim cell As Range
Dim r As Range
Dim s As Range
For Each cell In Range([a1], [a444])
If IsEmpty(cell) = False Then
Set r = cell.Offset(0, 4).End(xlDown) - where subtotals are.
'Summing cells ( subtotals )
cells(1,400).value = ' formula that would add up all subtotals.) i.e.
end if
next