trying to use sum with range & offest

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following gives me a Compile Error:Invalid Qualifier (highlights the Sum
word)

For x = 0 To 9
Range("B4").Activate
y = WorksheetFunction.Sum(Range(ActiveCell.Offset(x, 0),
ActiveCell.Offset(x, 23))).Value
Next

Whats wrong?
 
Give this a try...

For x = 0 To 9
Range("B4").Activate
y = Application.Sum(Range(ActiveCell.Offset(x, 0),
ActiveCell.Offset(x, 23))).Value
Next

or

For x = 0 To 9
Range("B4").Activate
y = Application.WorksheetFunction.Sum(Range(ActiveCell.Offset(x, 0),
ActiveCell.Offset(x, 23))).Value
Next
 
The second recommendation gave me the same original compile error. The first
got past the compile but gives me a runtime error '424' object required.
--------------------------------------------------------------------
 
Get rid of the .Value at the end of the statement...

For x = 0 To 9
Range("B4").Activate
y = WorksheetFunction.Sum(Range(ActiveCell.Offset(x, 0), _
ActiveCell.Offset(x, 23)))
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top