VBA code for Autosum command

M

Michelle

I know I've used this before but I can't locate it. I'm
trying to find the VBA code for the Excel 'Autosum'
command. I'm using Excel 2003.
Thanks!
 
J

Jim Rech

This is one way to make Autosum run by code:

Sub DoAutoSum()
Dim x As CommandBarControl
Set x = CommandBars.FindControl(ID:=226)
If Val(Application.Version) > 9 Then _
Set x = x.Controls(1)
x.Execute 'AutoSum
If Selection.Cells.Count = 1 Then
x.Execute 'Again to exit edit mode
End If
End Sub

Here's another:

Sub DoAutoSumWithSendKeys()
SendKeys "%={Enter}"
End Sub


--
Jim Rech
Excel MVP
|I know I've used this before but I can't locate it. I'm
| trying to find the VBA code for the Excel 'Autosum'
| command. I'm using Excel 2003.
| Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top