Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Sum Range in VBA Error ? 1

Status
Not open for further replies.

HobbitK

Technical User
Jan 14, 2003
235
US
Hi everyone .. in a worksheet to sum a Range the formula in a Cell is simply =Sum(RangeName). This works perfectly, I am trying to do the same thing in VBA and assign that total to a variable. I have an Integer variable dimensioned
Dim iFirstRange as Integer
then further in code I am trying iFirstRange = Sum(Rangename). I get an error on the word SUM. It says Sub or Function Not Defined.
Any ideas on how to do this?
Thanks
Michael
 
Hi HobbitK,

SUM is part of Excel, not VBA. You need to use WorksheetFunction.SUM.

Enjoy,
Tony
 
Tony ...
Thank you Sir! I am just learning VBA and could not find anything pointing me towards the WorkSheetFunction Keyword!
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top