Macro/VBA help. Insert Sum() to bottom of numbers, continuously in column, till end.

Kinsleigh

New Member
Joined
Apr 15, 2018
Messages
2
Hi Everyone,

I need some help to try to overcome this time consuming task in excel. I hope someone here can help.

I have a worksheet that I'm working on, which I have to insert a Sum() Function to the bottom of some numbers in a column to give me the total. (Im working on a single column)When I click the autosum() at the bottom of rows of numbers, Excel intelligently seem to know and auto sum all the numbers above and give me a Total value. Pretend this was 3 rows.

Repeat this process again, but the next time its 4 rows or 5 rows or x number of rows to autosum(). I have like 4000 rows and tonz of sum functions to insert. This is taking me along time to do. I created a macro, which seem promising, but failed, because the macro does not have the intelligent to autosum all the numbers above.

Basically, my macro is using relative Reference, and its. Control down, Control down, down, sum(), enter. end.

Again, the maceo does not have the intelligent to autosum all the numbers above.

Sub Macro11()
'
' Macro11 Macro
'


'
Selection.End(xlDown).Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C:R[-1]C)"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub

Please help. Thanks.
Kinsleigh



1
2
3
6 is total




12
2
3
5
22 is total




5
5
5
5
5
25 is total



<tbody>
</tbody>



<tbody>
</tbody>
 
Hello again Peter, sorry for the tardy reply as I had to step out. The negatives you describe are actually exactly how I want the summing to be performed so your coding fits my application perfectly. The only modification I made was to change "Error" to "". Now I wish I could buy you a beer but I see you're from the Canada of the south (Australia) and I'm from the Australia of the north (Canada) =) so it will be rather difficult! But I really want to thank your for saving my posterior, hope I could repay one day!
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
The only modification I made was to change "Error" to "".
Instead of doing that, consider just removing this bit of code altogether, so you only do anything if fr>0.

Rich (BB code):
    End Select
      If fr > 0 Then
        .FormulaR1C1 = "=SUM(R" & fr & "C:R[-1]C)"
      <del>Else</del>
        <del>.Value = ""</del>
      End If
  End With
End Sub

The negatives you describe are actually exactly how I want the summing to be performed so your coding fits my application perfectly. Now I wish I could buy you a beer but I see you're from the Canada of the south (Australia) and I'm from the Australia of the north (Canada) =) so it will be rather difficult! But I really want to thank your for saving my posterior, hope I could repay one day!
You're welcome. I'll look you up for that beer if I ever get to Canada. :biggrin: (y)
 
Upvote 0
Hi Rich, how would you make your first code on this thread a negative number please? for example, sum(range)*-1

Thank you,
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,052
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top