Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Retrieving name from command button on Worksheet

I'm using Excel 2000 under win2K and have several command buttons on a
worksheet and assigned the same macro to them.
In the macro I want to find out WHAT button has been clicked
(extracting a number I attached to a name to privide as parameter in a
function). I don't want to create a bunch of macro's just to identify
each command button separately.
How do I do that?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Retrieving name from command button on Worksheet

If you are using buttons from the Forms toolbar then
"Application.Caller" returns a string with the button name.
Extracting a single digit suffix from the button name
could work like this...

Sub CommonSubCalledByAllButtons()
Select Case Right$(Application.Caller, 1)
Case "1"
'do something
Case "2"
'don't do something
Case "3"
'do something else
Case "4"
'have lunch
End Select
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


wrote in message oups.com...
I'm using Excel 2000 under win2K and have several command buttons on a
worksheet and assigned the same macro to them.
In the macro I want to find out WHAT button has been clicked
(extracting a number I attached to a name to privide as parameter in a
function). I don't want to create a bunch of macro's just to identify
each command button separately.
How do I do that?

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 on worksheet Jack Excel Programming 4 June 12th 06 11:51 AM
command button on worksheet PhilC Excel Programming 1 May 19th 06 05:09 PM
Command Button to Hyperlink to a Different worksheet Mikeyboy Excel Programming 1 May 3rd 05 12:35 PM
How do I add a command button on a worksheet to "paste" from the . Jalifid Excel Worksheet Functions 0 March 13th 05 03:01 PM
Command button on a protected worksheet dad1nm Excel Programming 0 December 13th 04 07:53 PM


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