which commandbutton was pressed

RAYLWARD102

Well-known Member
Joined
May 27, 2010
Messages
529
How can I find out what commandbutton was just pressed in my userform.

example: msgbox commandbutton.caption

I know the above wont work but its what I want; just don't know how to get it. I do not want want to refer to the number of the button that was just pressed...example: msgbox commandbutton1.caption
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
what I'm really wanting to do is use the caption in the button that was pressed to determine which column to read from for the next procedure.
There are many buttons and I'd rather paste a generic code into each of them to set the variable from the caption of what ever button was pressed. I dont want to reference the actual button number. (just the button that was clicked!)
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,862
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top