using sum function excel

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Using sum function in Excel VBA

Using sum function in Excel VBA

resolvedResolved · High Priority · Version 2010

Graham has attended:
Excel VBA Intro Intermediate course

Using sum function in Excel VBA

I am trying to write a formula to sum three cells on one sheet and input the result into another sheet that I am generating for a report. (Very similar structure to teh exercise on the training course - but with a few variations).

I am getting the following error
"Compile error - Invalid qualifier"

The code causing the problem is
Sheets(Office & Dept).Cells(TargetRowCount, 8).Value = _
Application.WorksheetFunction.Sum(Sheets("Rep-Det").Range("a15").Cells(RowCount, 10), Sheets("Rep-Det").Range("a15").Cells(RowCount, 12)).Value

Range ("a15") is effectively an anchor point for the cells to work from - at least that is my intention.

What am I doing wrong?

Regards

Graham

RE: Using sum function in Excel VBA

Hi Graham, thanks for your query. I think there might be a problem at the start:

Sheets(Office & Dept)

...should be

Sheets("Office & Dept")

See if that helps.

Anthony

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Shortcut for accessing recently opened files

To get into recently opened Excel files without using your mouse, hold down Alt + F to open the File menu.

Recently opened files are listed down the bottom of the File menu - type in the number next to the file you wish to open and it should appear on your screen.

View all Excel hints and tips


Server loaded in 0.08 secs.