VBA Autosum Column

zkreflex

New Member
Joined
Jul 22, 2013
Messages
44
I need help with vba code that autosums column O two cells below the last row of data.

I am currently using the following code:

Range("O2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(2, 0).Select
Application.CommandBars("Standard").Controls("Autosum").Controls("Sum").Execute
SendKeys "{ENTER}", True

The problem is it switches over to editing after the autosum command and doesn't execute the sendkey correctly.


Thanks guys
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
How about...

Code:
Sub sumo()
Dim Values As Range
Set Values = Range("O2", Range("O1048576").End(xlUp))
Range("O1048576").End(xlUp).Offset(2) = Application.Sum(Values)
End Sub
 
Upvote 0
try

Code:
Sub Test()
Range("O" & Rows.Count).End(xlUp).Offset(2, 0).FormulaR1C1 = "=SUM(R2C:R[-2]C)"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,394
Members
449,155
Latest member
ravioli44

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