User Form command button caption

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,104
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi

So lets say i just created 50 command buttons, and let the command button names stay default generated.
But i change all of the captions to words.

Like below,

commandbutton1 caption set to CAT
commandbutton10 caption set to DOG
commandbutton5caption set to RAT

What im trying to get is if i click commandbutton1, a messgae box "CAT"

I know i can write msgbox commandbutton1.caption but i dont want to write out ll the commandbuttons, i want activebutton.caption

So i want the activecontrol caption. But i do not want to hard code each button, i just want 1 code fits all copy and paste.

so if i click commandbutton3000 and this had a caption set to HELLO, msgbox "HELLO"

Really has me stumped

thanks for looking

Dave
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
nevermind

I have the isse fixed, turns out as my button was in frame 1 it was causing me problems

VBA Code:
MsgBox Frame1.ActiveControl.Caption

thanks all

dave
 
Upvote 0
Solution

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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