PC Review


Reply
Thread Tools Rate Thread

Calling a Sub from Another Sheet

 
 
baconcow
Guest
Posts: n/a
 
      29th May 2008
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
 
Reply With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      29th May 2008
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.



---
Regards.
Norman
"baconcow" <(E-Mail Removed)> wrote in message
news:1CF13F14-8ED4-4EF1-8972-(E-Mail Removed)...
>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


 
Reply With Quote
 
baconcow
Guest
Posts: n/a
 
      29th May 2008
How do I call a sub that is on the standard module from the active worksheet?

"Norman Jones" wrote:

> 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.
>
>
>
> ---
> Regards.
> Norman
> "baconcow" <(E-Mail Removed)> wrote in message
> news:1CF13F14-8ED4-4EF1-8972-(E-Mail Removed)...
> >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

>
>

 
Reply With Quote
 
Norman Jones
Guest
Posts: n/a
 
      29th May 2008
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



---
Regards.
Norman


"baconcow" <(E-Mail Removed)> wrote in message
news:7CB51136-070D-4FEA-A13C-(E-Mail Removed)...
> How do I call a sub that is on the standard module from the active
> worksheet?
>
> "Norman Jones" wrote:
>
>> 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.
>>
>>
>>
>> ---
>> Regards.
>> Norman


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling name of Sheet as a Variable? thekeytothedoor Microsoft Excel Worksheet Functions 1 1st Jan 2010 08:48 AM
Calling an inactive sheet... RJH Microsoft Excel Programming 1 17th Jul 2006 04:23 AM
Calling a Sheet =?Utf-8?B?d3RhZGRlckBob3RtYWlsLmNvbQ==?= Microsoft Excel Programming 2 27th Sep 2005 04:30 PM
calling a cell from another sheet scottwilsonx Microsoft Excel Worksheet Functions 1 5th Aug 2004 03:21 PM
Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub? Scott Lyon Microsoft Excel Programming 3 19th Aug 2003 03:03 PM


Features
 

Advertising
 

Newsgroups
 


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