View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Passing a Sub's name as parameter

Stefi..

do you mean s'thing like:

Sub ProcA()
dim s as String
select case Range("A1").Value
case 1: s="Proc1"
case 2: s="Proc2"
case else: msgbox "invalid input": exit sub
end select

call ProcB(s)
end sub

Sub ProcB(sSubProc as string)
'do 'common' stuff

if sSubProc = "Proc1" then
call Proc1
elseif sSubProc = "Proc2" then
call Proc2
end if
'note:could have used another select case above :)
end sub

sub proc1()
end sub
sub proc2()
end sub


Instead of passing the argument
you could use a module level variable.




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Stefi wrote :

Hi All,
How can I pass the name of a Sub to be called to an other Sub (which
is expected to execute the call) as a parameter?
Stefi