- Local time
- Today, 06:59
- Joined
- Jul 9, 2003
- Messages
- 16,392
Hi all!
I want to detect when any command button is pressed in excel, extract the command button caption, and then use this in a single routine to perform an operation which is in fact highlighting part of a particular column(s).
In access you would use something like this to detect the particular control activated:
this does not work in excel, the equivalent appears to be:
I can get the value of the current cell, but I can't get the value of a "pressed" command button?
I think it may be because the command buttons are in a different collection, they appear to be in a collection called ".ShapeRange" but I am not sure!
I am having a head scratching moment, and I would appreciate if someone could point me in the right direction!
Cheers Tony
I want to detect when any command button is pressed in excel, extract the command button caption, and then use this in a single routine to perform an operation which is in fact highlighting part of a particular column(s).
In access you would use something like this to detect the particular control activated:
Code:
' Dim ctlCurrentControl As Control
' Set ctlCurrentControl = Screen.ActiveControl
this does not work in excel, the equivalent appears to be:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ctlCurrentControl As Worksheet
Set ctlCurrentControl = Sheet1
MsgBox "Name " & ActiveCell.Value
End Sub
I can get the value of the current cell, but I can't get the value of a "pressed" command button?
I think it may be because the command buttons are in a different collection, they appear to be in a collection called ".ShapeRange" but I am not sure!
I am having a head scratching moment, and I would appreciate if someone could point me in the right direction!
Cheers Tony