using sum function excel
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

replyReply Fri 19 Aug 2011, 14:39Delegate Graham said...

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

For upcoming training course dates see: Pricing & availability

replyReply Mon 22 Aug 2011, 11:43Trainer Anthony said...

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

 

Please browse our web site to find out more about
training in excel and other Microsoft training courses.

Excel tip:

Deleting a range of cells using the autofill handle

Firstly, select the range of cells for which you would like to clear the contents. Then drag the autofill handle to the the top left corner of the selection whilst holding down the shift key. Your selected contents should then be deleted.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard