Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I have 3 commandbuttons that all run the same piece of code. In the code, I want to identify in the peice of code which of the commandbuttons were clicked to run the code. I just want to get the name, like commandbutton1 or commandbutton2. Is this possible? thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way is to pass the name of the control to the procedure as a parameter.
The following illustrates....... Private Sub CommandButton1_Click() Call MyCode(CommandButton1.Name) End Sub Private Sub CommandButton2_Click() Call MyCode(CommandButton2.Name) End Sub Sub MyCode(myCB As String) MsgBox myCB End Sub -- Cheers Nigel "Sean" wrote in message ... Hi All, I have 3 commandbuttons that all run the same piece of code. In the code, I want to identify in the peice of code which of the commandbuttons were clicked to run the code. I just want to get the name, like commandbutton1 or commandbutton2. Is this possible? thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you are using command buttons from the control toolbox, just use
Me.CommandButton1.Name If it is from the Forms toolbar, use Application.Caller -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Sean" wrote in message ... Hi All, I have 3 commandbuttons that all run the same piece of code. In the code, I want to identify in the peice of code which of the commandbuttons were clicked to run the code. I just want to get the name, like commandbutton1 or commandbutton2. Is this possible? thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Commandbutton | Excel Programming | |||
CommandButton | Excel Programming | |||
CommandButton | Excel Programming | |||
CommandButton | Excel Programming | |||
Commandbutton | Excel Programming |