Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default activating a command button

I have a command button on sheet1 named george.
i want it to activate/run a command button on sheet2 named harry.
can i do this?
how?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default activating a command button

You have at least a couple of choices.

This is the code I used under the Sheet2 module.
Option Explicit
Sub George_Click()
MsgBox "hi from George"
End Sub

Notice that the Private keyword is gone. That's so the "Call" can find the
procedure.

This is the code under the Sheet1 module:
Option Explicit
Private Sub Harry_Click()
Call Sheet2.George_Click
End Sub

=========
Another way:
Under Sheet2:
Option Explicit
Private Sub George_Click()
MsgBox "hi from George"
End Sub

Notice that the Private keyword is back.

And under Sheet1:
Option Explicit
Private Sub Harry_Click()
Application.Run "Sheet2.George_Click"
End Sub

(in both of these cases, that Sheet2 is the code name for the sheet--not the
name you see in excel on the sheet tab.)

=======
And one more way:
Under Sheet2:
Option Explicit
Private Sub George_Click()
MsgBox "hi from George"
End Sub

Under Sheet1:
Option Explicit
Private Sub Harry_Click()
Worksheets("Sheet2").OLEObjects("George").Object.V alue = True
End Sub




chuck wrote:

I have a command button on sheet1 named george.
i want it to activate/run a command button on sheet2 named harry.
can i do this?
how?


--

Dave Peterson
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
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Command Button Freshman Excel Worksheet Functions 3 September 2nd 08 01:16 PM
Command Button Freshman Excel Worksheet Functions 6 June 1st 07 07:15 AM
How to add a command button Marilyn Excel Discussion (Misc queries) 3 August 3rd 06 01:44 AM
Command Button Steved Excel Worksheet Functions 2 February 19th 06 11:01 PM


All times are GMT +1. The time now is 07:23 AM.

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"