Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a function with parameters pay99,pay00,pay01,pay02, etc., and in
my code I have declared a variable named cParam. If cParam equals the string "pay02", what function or expression do I use on cParam to get the value of parameter pay02? Many thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A large case statement:)
No but seriously, if you have a function that has a whole slew of parameters of the same type/meaning, you need a paramarray, check XL help to see how that works. From there you can say Myval = PrmPay(99) to get the 99th parameter. Besides this advantage, it also keeps the parameters optional. If you only need 88 that would work without any problem. DM Unseen |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't believe there is an arglist type functionality as in C, so I believe
you would have to hard code a case statement Select Case cParam Case "pay99" s = pay99 Case "pay00" s = pay00 Case "pay01" s = pay01 Case "pay02" s= pay02 Case Else s = "" End Select Another approach would be to use a paramarray and not define you arguments. Function MyFunction(ParamArray v()) cParem = 2 MyFunction = v(cParem - 1) End Function Sub Tester1() MsgBox MyFunction("A", "B", "C", "D") End Sub the message box returns B -- Regards, Tom Ogilvy "CR" wrote in message oups.com... I have a function with parameters pay99,pay00,pay01,pay02, etc., and in my code I have declared a variable named cParam. If cParam equals the string "pay02", what function or expression do I use on cParam to get the value of parameter pay02? Many thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks so much. Works great!
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Evaluating division by zero | Excel Worksheet Functions | |||
VBA for Evaluating Integrals | Excel Programming | |||
Evaluating Week No. | Excel Programming | |||
Evaluating a cell | Excel Programming | |||
Evaluating a range | Excel Programming |