Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub Routine Names As Variables
I have a procedure which passes the names of other sub routines (Sub1,
Sub2 Sub3)to a variable ("PriceOPtion"). I set up the variable within a Select Case statment before my main code. Thus the Case will decide which name gets passed to the PriceOPtion variable. When the main code runs, the sub which was passed to the variable gets called. Example: Select Case Case Is = 1 PriceOPtion = Sub1 Case Is = 2 PriceOPtion = Sub1 Case Is = 3 PriceOPtion = Sub1 End Select Loop Logic of Main Code Call PriceOPtion Loop Logic of Main Code However, I have a 4th case where I do not want any of the Subs called. I can put an if in the main code that bypasses the Call statment. Is there a way that I can pass a dummy variable to PriceOPtion such that I can avoid the if stmt in the main code? That is I want to call PriceOPtion in Case 4, but I want the code to not call a thing and simply progress through the call as if nothing happened. Select Case Case Is = 1 PriceOPtion = Sub1 Case Is = 2 PriceOPtion = Sub1 Case Is = 3 PriceOPtion = Sub1 Case Is = 4 PriceOption = DummaryVariable End Select Loop Logic of Main Code Call PriceOPtion Loop Logic of Main Code Thanks TS |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub Routine Names As Variables
if priceoption is not the name of a subroutine, then call priceoption will
fail. assume the variable you do your case statement on is inum Select Case inum rather than do that you could do if inum 0 and inum < 3 then application.Run "Sub" & inum End if -- Regards, Tom Ogilvy wrote in message om... I have a procedure which passes the names of other sub routines (Sub1, Sub2 Sub3)to a variable ("PriceOPtion"). I set up the variable within a Select Case statment before my main code. Thus the Case will decide which name gets passed to the PriceOPtion variable. When the main code runs, the sub which was passed to the variable gets called. Example: Select Case Case Is = 1 PriceOPtion = Sub1 Case Is = 2 PriceOPtion = Sub1 Case Is = 3 PriceOPtion = Sub1 End Select Loop Logic of Main Code Call PriceOPtion Loop Logic of Main Code However, I have a 4th case where I do not want any of the Subs called. I can put an if in the main code that bypasses the Call statment. Is there a way that I can pass a dummy variable to PriceOPtion such that I can avoid the if stmt in the main code? That is I want to call PriceOPtion in Case 4, but I want the code to not call a thing and simply progress through the call as if nothing happened. Select Case Case Is = 1 PriceOPtion = Sub1 Case Is = 2 PriceOPtion = Sub1 Case Is = 3 PriceOPtion = Sub1 Case Is = 4 PriceOption = DummaryVariable End Select Loop Logic of Main Code Call PriceOPtion Loop Logic of Main Code Thanks TS |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub Routine Names As Variables
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
find maximum and minum variables for multiple names | Excel Worksheet Functions | |||
Inserting variables within file names | Excel Worksheet Functions | |||
Routine?? | Excel Programming | |||
Need VBA Routine | Excel Programming | |||
variables for file names | Excel Programming |