Running Macro Code from a Module when it is a Sub in a WS

EE Pros,

What code do I use to run a macro from a Module,  when  the macro I want to run is in a specific WS?  Do I have to declare the WS in the Module Code, or can I simply direct it with a single line in the Module code instructing the code to execute a Macro that is located in the WS?

Thank you in advance.

Who is Participating?
Martin LissConnect With a Mentor Older than dirtCommented:
Try this. I moved the macro to newly created Module1.
Martin LissOlder than dirtCommented:
The best thing to do is to move the macro to the Module and make it Public. You can then call it from worksheet events or any other module procedure.
ste5anConnect With a Mentor Senior DeveloperCommented:
It depends only on the macro and how it references your worksheet. You need either to give the macro the worksheet name or index or it runs on the ActiveWorksheet object. In the first case you need further interaction/macro code. In the second case just activate the desired worksheet, then run your macro.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Rgonzo1971Connect With a Mentor Commented:
You can use the sheet code (not the name)
like this
Call Sheet1.MyMacroInSheet1

Open in new window

Roy CoxConnect With a Mentor Group Finance ManagerCommented:
Macros should not really be stored in the WorkSheet.
Bright01Author Commented:
Roy,  Thanks for the comment.  Here's the challenge;  I'm simply trying to piece together the code you wrote previously for Save/Restore that had the Msg. confirmation (i.e. "Success") and have it display the confirmation in a cell rather then a msg. or a "shape".   I've been troubleshooting the code for several hours but cannot get it to work.
Bright01Author Commented:
Here is the macro that I was starting to incorporate.
Bright01Author Commented:
Hey guys.....  you all gave me good advice on this challenge..... however, I realized after trying to incorporate everyone's suggestions that I was not going to be able to integrate something that should be simple as a stand alone question.  Therefore I have awarded the answers and closed the question only to open up a new one with the actual code that requires embedding the logic to change a msg box to a cell reference for the confirmation of data being saved and restored.  With the full file, you can see what I'm simply trying to accomplish.

Thank you all... and I hope one of you will pick up the new post.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.