View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] terryspencer2003@yahoo.ca is offline
external usenet poster
 
Posts: 32
Default 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