ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call vs. Run command (https://www.excelbanter.com/excel-programming/302000-call-vs-run-command.html)

Chris McFarland

Call vs. Run command
 
I am a little cofused between the Call and Run commands.
I have a hidden worksheet (testfile.xls) that loads every
time excel is open (Note: Thisworksheet.isaddin = True &
Macro Security Level is set to Medium).

From a new workbook I want to create a button that calls
a subroutine, MySub(), from testfile.xls. I tried to use:
Call MySub()
but it was not recognized. After a little research, I
used:
Run "MySub()"
and it seems to work. My question is what is the
difference between the Run and Call Commands? I thought
they were essentially the same functions.

Tom Ogilvy

Call vs. Run command
 
Call only works with procedures within the scope of the current project.
This includes the module with the code, public modules in the workbook and
similar modules in any workbook which this workbook has a reference set to
(in tools = reference in the VBE).

Run will execute a macro in another workbook if it can be found.

--
Regards,
Tom Ogilvy


"Chris McFarland" wrote in message
...
I am a little cofused between the Call and Run commands.
I have a hidden worksheet (testfile.xls) that loads every
time excel is open (Note: Thisworksheet.isaddin = True &
Macro Security Level is set to Medium).

From a new workbook I want to create a button that calls
a subroutine, MySub(), from testfile.xls. I tried to use:
Call MySub()
but it was not recognized. After a little research, I
used:
Run "MySub()"
and it seems to work. My question is what is the
difference between the Run and Call Commands? I thought
they were essentially the same functions.





All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com