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

using sum function excel

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

ResolvedVersion 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:

Enter formulae into multiple cells

If a formula is to be used in a series of cells, select the cells first. Now type in your formula and hold the Ctrl key while you press Enter. This enters the formula in each selected cell.

Just be careful with your absolute and relative cell references.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.