Call a Visual Basic Function with VLookup
I want to determine which function
to run based on a vlookup of a list of the functions in a table.
Here's one way that comes to mind if I understand the question correctly:
Sub Demo()
Dim n, m
Dim Ans
n = 2
m = WorksheetFunction.Lookup(n, Array(1, 2, 3), Array("Jan", "Feb",
"Mar"))
Ans = Run(m, 2, 3)
End Sub
Function Feb(x, y)
Feb = x ^ 2 + y ^ 2
End Function
--
HTH :)
Dana DeLouis
Windows XP & Excel 2007
"ajd" wrote in message
...
I wrote a few functions in Visual Basic. I want to determine which
function
to run based on a vlookup of a list of the functions in a table. So I
have a
table that has:
A FunctionA
B FunctionB
I want to do a vlookup on A to run FunctionA, and also provide the
variable
for Function (which does not depend on the specific function to be run).
I
can't figure out a way for vlookup to not just return text, but return a
function to run, and then also provide the variables for that function to
run
on.
Thanks.
|