View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Ring Dave Ring is offline
external usenet poster
 
Posts: 20
Default VBA -- procedures as arguments?

I would like to pass a VBA subroutine as an argument to another VBA
subroutine. If I pass the name of the variable subroutine as a string
and execute it using a Run statement in the host subroutine, the result
is significantly slower than if I put a Select/Case statement in the
host subroutine that directly calls the variable subroutine. E.g., if
ProcName1 is a string containing the name of procedure NamedProc1, then

Sub HOSTSUB(ProcName As String)
Run ProcName
End Sub

is slower than

Sub HOSTSUB(ProcName As String)
Select Case ProcName
Case ProcName1
NamedProc1
End Select
End Sub

Is there a better way to handle variable procedures in VBA?

Dave Ring