calling/running a macro on another worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Lets say I have a CommandButton (call it Button1) on Sheet1 that does some
calculations using cells on Sheet1 and Sheet2

On Sheet2 I have another CommandButton (call it Button2) that alters some of
the cells that are used when Button1 is clicked.

I would like to add a macro to Sheet2 so that I could run the
"CommandButton_Click()" macro on Sheet1. What would be the syntax for doing
this?

Thanks.
 
Hi Sunny,

Try something like:

'=============>>
Public Sub Tester()
Dim SH As Worksheet
Dim oleObj As OLEObject

Set SH = ThisWorkbook.Sheets("Sheet1")
Set oleObj = SH.OLEObjects("CommandButton1")
oleObj.Object.Value = True
End Sub
'<<=============
 
Back
Top