Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Which button did I push

I have two command butons on an Excel page, both assigned
to the same macro. Let's say the function of the macro
is to make the cell to the right of the button blue shade.

How can I tell which button was pushed?

For example:

Sub WhichButton

Select Case ButtonPushed.Top
Case 100
Range("c10").interior.colorindex = 5
Case <=100
Range("c50").interior.colorindex = 5
End Select

End Sub

Thanks
Daniel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Which button did I push

Daniel,

Application.Caller returns the name of the calling button:

Select Case Sheet1.Buttons(Application.Caller).Top
Case Is 100
Range("c10").Interior.ColorIndex = 5
Case Is <= 100
Range("c50").Interior.ColorIndex = 5
End Select

hth,

Doug Glancy

"Daniel Bonallack" wrote in message
...
I have two command butons on an Excel page, both assigned
to the same macro. Let's say the function of the macro
is to make the cell to the right of the button blue shade.

How can I tell which button was pushed?

For example:

Sub WhichButton

Select Case ButtonPushed.Top
Case 100
Range("c10").interior.colorindex = 5
Case <=100
Range("c50").interior.colorindex = 5
End Select

End Sub

Thanks
Daniel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Which button did I push

Hi Daniel

If you use buttons from the Forms Tool bar you can use
Application.Caller

Sub a()
MsgBox ActiveSheet.Shapes(Application.Caller).BottomRight Cell.Address
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Daniel Bonallack" wrote in message ...
I have two command butons on an Excel page, both assigned
to the same macro. Let's say the function of the macro
is to make the cell to the right of the button blue shade.

How can I tell which button was pushed?

For example:

Sub WhichButton

Select Case ButtonPushed.Top
Case 100
Range("c10").interior.colorindex = 5
Case <=100
Range("c50").interior.colorindex = 5
End Select

End Sub

Thanks
Daniel



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Which button did I push

Daniel,

You can use the Application.Caller property to get the name of
the button that was clicked. E.g.,

Dim SH As Shape
Set SH = ActiveSheet.Shapes(Application.Caller)
MsgBox "You clicked: " & SH.Name


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Daniel Bonallack" wrote in message
...
I have two command butons on an Excel page, both assigned
to the same macro. Let's say the function of the macro
is to make the cell to the right of the button blue shade.

How can I tell which button was pushed?

For example:

Sub WhichButton

Select Case ButtonPushed.Top
Case 100
Range("c10").interior.colorindex = 5
Case <=100
Range("c50").interior.colorindex = 5
End Select

End Sub

Thanks
Daniel



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Which button did I push

Ron, Doug,
Thank you very much
Daniel
-----Original Message-----
Hi Daniel

If you use buttons from the Forms Tool bar you can use
Application.Caller

Sub a()
MsgBox ActiveSheet.Shapes

(Application.Caller).BottomRightCell.Address
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Daniel Bonallack" wrote in

message ...
I have two command butons on an Excel page, both

assigned
to the same macro. Let's say the function of the macro
is to make the cell to the right of the button blue

shade.

How can I tell which button was pushed?

For example:

Sub WhichButton

Select Case ButtonPushed.Top
Case 100
Range("c10").interior.colorindex = 5
Case <=100
Range("c50").interior.colorindex = 5
End Select

End Sub

Thanks
Daniel



.

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
Push button and input box? tripflex Excel Discussion (Misc queries) 2 March 6th 09 03:36 PM
Time with the push of one button Dale G[_2_] New Users to Excel 7 August 6th 08 01:55 PM
Push button paste special? pugsly8422 Excel Discussion (Misc queries) 4 June 7th 06 03:26 PM
push button paste special pugsly8422 Excel Discussion (Misc queries) 2 June 7th 06 02:32 PM
Searching in a row with push on a button Christian R. Excel Programming 0 January 21st 04 07:16 PM


All times are GMT +1. The time now is 12:59 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"