Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default calling/running a macro on another worksheet

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default calling/running a macro on another worksheet

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
'<<=============


---
Regards,
Norman



"Sunny" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default calling/running a macro on another worksheet

Thanks for the help, Norman. Does exactly what I needed it to.

"Norman Jones" wrote:

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
'<<=============


---
Regards,
Norman



"Sunny" wrote in message
...
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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a macro from Worksheet--Activate Fatz Excel Discussion (Misc queries) 3 March 5th 08 11:07 PM
Report with macro losing links to a particular worksheet after running macro santhu Excel Programming 0 March 1st 07 03:25 AM
calling worksheet function from a macro Joe Farruggio Excel Worksheet Functions 3 November 20th 06 10:01 PM
Program calling up Excel - Not running Macro kraljb[_4_] Excel Programming 1 May 28th 05 06:23 AM
Calling a macro in another worksheet Tolga[_2_] Excel Programming 2 August 5th 04 07:03 PM


All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"