Using WorksheetFunction.Max()

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

Guest

I have a worksheet where A1:A10 is a named range "Line"
and C1:C10 is named "Qty".
Each cell in "Line" has the formula =IF(ISNUMBER(Qty),ROW(),"")
The worksheet function =Max(Line) will return the highest value in the range
"Line".
When I try to use WorksheetFunction.Max(Line) in VBA, it always returns 0
(zero).
How can I correctly use the code to match the results of the worksheet
function?
Thanks very much.
 
Try this
WorksheetFunction.Max(Range(Line))

The names on the worksheet are just strings like "A1:G7" which is not a range.
 
Hi Dave,

WorksheetFunction.Max(Range("Line"))

Using line the way you did VBA thinks that it is a VBA variable not a named
range.



Regards,

OssieMac
 
I've struggled with understanding when to use quotes and when not to.
Thanks to all for the help.
 

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