In Excel 2003, Using sheet type activex command buttons, I would like to be able to have code in one button that will give me the name (in a msgbox) of the previous button that was clicked .
Thanks
In Excel 2003, Using sheet type activex command buttons, I would like to be able to have code in one button that will give me the name (in a msgbox) of the previous button that was clicked .
Thanks
In the sheet's code module:
[VBA]Dim LastButtonClicked As String' global variable. Put at top of module.
Private Sub CommandButton1_Click()
LastButtonClicked = CommandButton1.Name
'LastButtonClicked = CommandButton1.Caption
End Sub
Private Sub CommandButton2_Click()
LastButtonClicked = CommandButton2.Name
'LastButtonClicked = CommandButton2.Caption
End Sub
Private Sub CommandButton3_Click()
LastButtonClicked = CommandButton3.Name
'LastButtonClicked = CommandButton3.Caption
End Sub
Private Sub CommandButton4_Click()
LastButtonClicked = CommandButton4.Name
'LastButtonClicked = CommandButton4.Caption
End Sub
Private Sub CommandButton5_Click() 'This is the new button.
MsgBox LastButtonClicked
End Sub
[/VBA]
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Thank you Sir
(another one I should have realized on my own)