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!

WorkSheetFunction Error 1004 2

Status
Not open for further replies.

HobbitK

Technical User
Jan 14, 2003
235
US
Hi everyone ...
Trying to Sum a named Range in VBA and assign that to a variable.

Here is the line of code
iLastbalance = WorksheetFunction.Sum("LastBalance")

iLastBalance is an argument in a Function.

When the code runs I get an error box saying "RunTime Error 1004: Unable to get the Sum property of the WorkSheetFunction Class"

Any ideas?
Michael
 
Assuming you have a range defined with the name "LastBalance" and you are trying to sum all of the cells in that range, then all you need to do is modify one line of code as follows:
Code:
 iLastbalance = WorksheetFunction.Sum(
[blue]
Code:
Range(
[/color]
Code:
"LastBalance"
[blue]
Code:
)
[/color]
Code:
)

 
Zathras,
Thank-you Sir. I had tried WorksheetFunction.Sum.Range,
but never thought to put it inside a ()
Thaks again,
Michael
 
Have a star for that one Bryan, but can you tell me where it's documented.

Tony
 
Have a look at the evaluate method - square brackets are a shorthand way of invoking it.

cheers matey.

Bryan.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top