How do I assign value of formula to a variable?

G

Guest

I want to assign the value a formula to a variable. In a sheet named Data I
have range of cells a1:g200 that contain values. I want to assign the
maximum value to myVariable.

I've tried:

myVariable = Max(Range("Data!a1:g200")).Value

but I get an error 'Sub or Function not defined.

Thanks for any help.
 
D

Dave Patrick

myVariable = Application.WorksheetFunction.Max(Range("a1:g200"))

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I want to assign the value a formula to a variable. In a sheet named Data
I
| have range of cells a1:g200 that contain values. I want to assign the
| maximum value to myVariable.
|
| I've tried:
|
| myVariable = Max(Range("Data!a1:g200")).Value
|
| but I get an error 'Sub or Function not defined.
|
| Thanks for any 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

Top