ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code for Autosum command (https://www.excelbanter.com/excel-programming/302455-vba-code-autosum-command.html)

Michelle

VBA code for Autosum command
 
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!

Jim Rech

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!




All times are GMT +1. The time now is 03:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com