View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Run Macro in one worksheet from a button on another worksheet

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.
--
Gary's Student


"joecrabtree" wrote:

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