Run Macro in one worksheet from a button on another worksheet

J

joecrabtree

To all,

I have written a macro that does various things in a worksheet called
DATA. At the moment I am running in by using a button in this
worksheet, so that when the user clicks it, it runs.

However I wish to place a button on the main worksheet called WELCOME
and to run the macro in the DATA spreadsheet. Is it possible to do this
without rewriting the macro that I have in the DATA worksheet?

Thanks in advance,

Regards

Joseph Crabtree
 
G

Guest

As the macro executes, it needs to know on what sheet to perform its
operations:


Sub demo()
Dim ws As Worksheet
Set ws = Sheets("DATA")
ws.Range("A1").Value = 1
End Sub

tells the macro that DATA is the sheet to change, not the ActiveSheet.
 
B

bz

To all,

I have written a macro that does various things in a worksheet called
DATA. At the moment I am running in by using a button in this
worksheet, so that when the user clicks it, it runs.

However I wish to place a button on the main worksheet called WELCOME
and to run the macro in the DATA spreadsheet. Is it possible to do this
without rewriting the macro that I have in the DATA worksheet?


If your macro is NOT 'private' you should be able to access it from any
sheet in the workbook. Have you tried attaching it to a button on the
WELCOME worksheet?





--
bz

please pardon my infinite ignorance, the set-of-things-I-do-not-know is an
infinite set.

(e-mail address removed) remove ch100-5 to avoid spam trap
 

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