excel vba call and
Request a callback

We'll call during UK business hours

Name:
Number:
0207 987 3777
STL

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA: Call and Run

Excel VBA: Call and Run

resolvedResolved · Medium Priority · Version 2003

Tue 28 Apr 2009, 10:35 replyReply Delegate Simon said...

Simon has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course

Excel VBA: Call and Run

Guys,

What is the difference between a CALL statement and a RUN method?

I have been happily calling sub-procedures since my course (okay, I've done it once or twice), however I recently tried to do this in an inherited spreadsheet and I got an error message (which I can't remember). I noticed that a couple of other sub-procedures that were there already were 'run'.

With a bit of experementation I have established that both versions of the syntax below produce the same result (as far as I can see):

[...] Call SelectOpeningIndicator
Call ToggleToolbars
Call showbars
[...]

OR

[...] Run "SelectOpeningIndicator"
Run "ToggleToolbars"
Run "showbars"
[...]

so what's the difference?

Cheers,

S!


For upcoming training course dates see: Pricing & availability

Thu 30 Apr 2009, 16:13 replyReply Trainer Anthony said...

RE: Excel VBA: Call and Run

Hi Simon. Call and Run may seem to be interchangeable, but Calling a procedure from within the code is "tidier" (in the memory usage sense) than Running it, and I suspect this has caused the errors you encountered. The "call" command invokes a named procedure (and you would normally "call" a procedure from another procedure in a program, rather than "run" it) whereas Run invokes a procedure (and probably resets all your variable declarations) which happens to be named. "Run" is a command which you'll recognise even from the version of BASIC on a ZX Spectrum, and earlier - "Execute" is used on different platforms for similar purposes - whereas "Call" is the programmatic, procedural equivalent and using the two commands interchangeably has processing, variable declaration, ramifications. In a nutshell, the difference is one of arcane programming requirements and when coding I'd "Call" my procedures!

Hope this helps,

Anthony

Fri 1 May 2009, 10:28 replyReply Delegate Simon said...

RE: Excel VBA: Call and Run

Anthony,

Thanks, this is useful to know. (I wrote my first code on a ZX81, although I have been out of a coding environment since the end of the 1980s).

I suspect that the 'Run' commands that I have inherited are some kind of legacy programming and I am replacing 'Runs' with 'Calls' as I come across them. This has gone okay... so far!

Cheers,

S!


 

Excel tip:

Use the Ctrl-key for quick navigation in Excel 2010

If you want to move quickly to the right, left, top or bottom of your spreadsheet, just press Ctrl and one of the arrow keys. If you want to then select all the data in that particular row or column, hold down the Shift key and press Ctrl and an arrow key.

View all Excel hints and tips

Training classes
London & UK

Live dates & prices »

On-site training

60-second quote »

E-Learning

From £99 · Call us »

Mailing list

Sign up for latest offers »

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.



Excel training
Course rating
4.7 stars - based on 24911 reviews
Microsoft Certified Partner Institute of Leadership and Management - Certified Courses Learning and Performance Institute - Accredited Training Provider Security Seal verified by visa, mastercard securecard

Connect with us: Google+ · Facebook · Twitter · LinkedIn · Pinterest

2nd Floor, CA House, 1 Northey Street
Limehouse Basin, London, E14 8BT
United Kingdom

info@microsofttraining.net

Resources