JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
Suppose in Sheet1, I have given the cell C4 the name "MaxValue" and MaxValue (C4) contains the value "100".
Is there a way that a UDF called from any cell in Sheet1 can access the value in C4 using the name MaxValue without passing it as an argument?
I am working on a UDF that needs a bunch of values (8-10 and growing). Passing them as parameters is getting tedious and error-prone as they can easily get out of order. I would prefer that the UDF be able to access the values in the named cells using the cell names.
This is what I tried, but it gets a Value error.
Thanks
Is there a way that a UDF called from any cell in Sheet1 can access the value in C4 using the name MaxValue without passing it as an argument?
I am working on a UDF that needs a bunch of values (8-10 and growing). Passing them as parameters is getting tedious and error-prone as they can easily get out of order. I would prefer that the UDF be able to access the values in the named cells using the cell names.
This is what I tried, but it gets a Value error.
Code:
Public Function MyFun()
. . .
Const MaxValue as String = "MaxValue" 'Name of cell in Sheet1
Dim MaxVal as Integer
MaxVal = Range(MaxValue).Value
. . .
End Function
Thanks