Calling a Sub from Another Sheet

B

baconcow

I have multiple sheets all running code. However, there are times when I
would rather call a sub from another worksheet instead of duplicating the
code.

I used Call SubName to call it from the active sheet. What is the syntax for
calling it from say, Sheet1(Surface) instead of the current Sheet13(Intro)

Also, is there any way to organize the "Sheet1", "Sheet2", etc? Under
Microsoft Excel Objects, the actual order of the sheets is so out of order.
The "SheetX" name seems to be given when the sheets are created. Can this be
changed to better sort them?

Thanks
 
N

Norman Jones

Hi Baconcow,

Try moving these subs to a standard module:

In the VBE,

Menu | Insert | Module.

A worksheet modul should normally only be
used for worksheet event code.
 
N

Norman Jones

Hi Baconcow,

============
How do I call a sub that is on the standard module from the active
worksheet?
============

If you refer to calling a sub in a standard module
from worksheet event code, try:

Call myMacro

In fact, the same would apply to non event code
but, as indicated previously, a worksheet module
should normally only house worksheet event code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top