PC Review


Reply
Thread Tools Rate Thread

calling/running a macro on another worksheet

 
 
=?Utf-8?B?U3Vubnk=?=
Guest
Posts: n/a
 
      10th Apr 2007
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 With Quote
 
 
 
 
Norman Jones
Guest
Posts: n/a
 
      10th Apr 2007
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" <(E-Mail Removed)> wrote in message
news:AE20BD3F-E246-4F24-A418-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?U3Vubnk=?=
Guest
Posts: n/a
 
      10th Apr 2007
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" <(E-Mail Removed)> wrote in message
> news:AE20BD3F-E246-4F24-A418-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for calling the previous worksheet Balkar Microsoft Excel Programming 3 30th Sep 2009 08:51 AM
Calling a macro from Worksheet-->Activate Fatz Microsoft Excel Misc 3 5th Mar 2008 11:07 PM
calling worksheet function from a macro Joe Farruggio Microsoft Excel Worksheet Functions 3 20th Nov 2006 10:01 PM
Program calling up Excel - Not running Macro kraljb Microsoft Excel Programming 1 28th May 2005 06:23 AM
Calling a macro in another worksheet Tolga Microsoft Excel Programming 2 5th Aug 2004 07:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:23 PM.