Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA -- procedures as arguments?

Dave,

If you pass the procedure name as a string, you can use Application.Run to
execute it. E.g.,

Application.Run ProcName

i

"Dave Ring" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Separating sub procedures JAW Excel Discussion (Misc queries) 4 January 28th 09 12:17 PM
Pivotcharts and stored procedures omar_aa Charts and Charting in Excel 5 October 9th 08 02:35 AM
VBA function Procedures.... Arif[_2_] Excel Worksheet Functions 1 June 3rd 08 01:54 PM
VBA functions and Procedures.... Arif[_2_] Excel Worksheet Functions 1 June 3rd 08 10:27 AM
Splitting Procedures Markus Excel Programming 4 August 26th 03 05:47 PM


All times are GMT +1. The time now is 09:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"