Just Curious

5 views
Skip to first unread message

John Wilson

unread,
Dec 24, 2001, 8:52:47 PM12/24/01
to
What's the difference between "Run" and "Call" from within VBA??

Just Curious

Chip Pearson

unread,
Dec 25, 2001, 8:42:10 AM12/25/01
to
"Call" is used to call procedures within the same project or a project
referenced by the current project. It is part of the VBA language. You don't
need to use the Call keyword -- it is unnecessary. The procedure named in the
Call statement is linked at compile time, and therefore you can't use it to call
a procedure named in a variable. For example, the following code won't work.

Dim ProcName As String
ProcName = "BBB"
Call ProcName

"Run" is used to execute procedures in another workbook. It is part of the
Excel object model, not part of VBA itself. The procedure referenced in Run is
found at run time, and therefore you can use it to call a procedure named in a
variable. For example, the following code will work fine.

Dim ProcName As String
ProcName = "BBB"
Application.Run ProcName

It takes less overhead to execute a procedure using Call (or by omitting it)
than to execute a procedure with Run.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com ch...@cpearson.com

"John Wilson" <jwi...@optonline.net> wrote in message
news:3C27DBEF...@optonline.net...

John Wilson

unread,
Dec 25, 2001, 9:16:21 AM12/25/01
to
Chip,

Thanks for the explanation.
I had a mixture of "runs" and "calls" in various code and never knew the difference
(only cared that they worked).
Overhead is at a premium in a couple of my projects, so this will help.

Thanx,
John

Reply all
Reply to author
Forward
0 new messages