View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default VBA code for Autosum command

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
"Michelle" wrote in message
...
|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!