Find name of userform control

Dean76

New Member
Joined
Apr 17, 2016
Messages
37
Hi,

Does anyone know if it is possible to extract a control name from a multipage on a userform upon actioning the control?

I have CheckBox1 and, when it is directly on the userform (no multipage), using the code Me.ActiveControl.Name returns CheckBox1 on click - which is exactly what I am after.

The problem arises as soon as i place CheckBox1 on a multipage then Me.ActiveControl.Name returns MultiPage1.

Is there a way around this so I can still extract the checkbox name whilst it is on a multipage?

Thanks for help!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
As long as you won't be nesting container controls, you could use:

Code:
    Select Case TypeName(Me.ActiveControl)
        Case "MultiPage"
            MsgBox Me.ActiveControl.SelectedItem.ActiveControl.Name
        Case "Frame"
            MsgBox Me.ActiveControl.ActiveControl.Name
        Case Else
            MsgBox Me.ActiveControl.Name
    End Select

If they might be nested, you'd need a loop to keep iterating until you reached a non-container type control.
 
Upvote 0
Select Case TypeName(Me.ActiveControl) Case "MultiPage" MsgBox Me.ActiveControl.SelectedItem.ActiveControl.Name Case "Frame" MsgBox Me.ActiveControl.ActiveControl.Name Case Else MsgBox Me.ActiveControl.Name End Select
Perfect, that's saved a couple of hours of repetitive typing - thanks!
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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