ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel sum function IN VBA (https://www.excelbanter.com/excel-programming/279391-excel-sum-function-vba.html)

Sobhani Hafiz

Excel sum function IN VBA
 
HI ,

Is it possible to use the excel sum function in VBA? I recorded a macro to
with Excel sum, Then I changed the row number and tried to run from VBA. It
seems that it didnt run.

Any help will be greatly appreciated.

Arefin



Jerry W. Lewis

Excel sum function IN VBA
 
Current versions will recognize
Application.Sum()
WorksheetFunction.Sum()
Application.WorksheetFunction.Sum()

Some older versions will only recognize
Application.Sum()

Jerry

Robin Hammond wrote:

This is probably what you want

Sub Sum()
MsgBox (Application.WorksheetFunction.Sum(Sheets(1).Range ("a1:a2")))
End Sub

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in

"Sobhani Hafiz" wrote in message
...

HI ,

Is it possible to use the excel sum function in VBA? I recorded a macro to
with Excel sum, Then I changed the row number and tried to run from VBA.

It

seems that it didnt run.

Any help will be greatly appreciated.

Arefin



Tom Ogilvy

Excel sum function IN VBA
 
Added comment:
Older versions being xl5 and xl95. WorksheetFunction was introduced in
xl97.

--
Regards,
Tom Ogilvy

"Jerry W. Lewis" wrote in message
...
Current versions will recognize
Application.Sum()
WorksheetFunction.Sum()
Application.WorksheetFunction.Sum()

Some older versions will only recognize
Application.Sum()

Jerry





Robin Hammond[_2_]

Excel sum function IN VBA
 
This is probably what you want

Sub Sum()
MsgBox (Application.WorksheetFunction.Sum(Sheets(1).Range ("a1:a2")))
End Sub

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in

"Sobhani Hafiz" wrote in message
...
HI ,

Is it possible to use the excel sum function in VBA? I recorded a macro to
with Excel sum, Then I changed the row number and tried to run from VBA.

It
seems that it didnt run.

Any help will be greatly appreciated.

Arefin






All times are GMT +1. The time now is 08:45 AM.

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