Sub event that evaluates changing label in UserForm???

MistakesWereMade

Board Regular
Joined
May 22, 2019
Messages
103
I have a label that changes occasionally. If this label is one thing, I want the CommandButtons in my userform to be locked... If it is the other option, I want the command buttons to be unlocked. I've tried to use Label1_Change() but it doesn't seem to work. Any ideas on how I might achieve this?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi,
Label control does not have a change event (double click the control in the editor & in dropdown on right you will see all available events for selected control)
- you should be able to manage the enabled state of your commandbuttons via the code that changes the label caption
If not sure how to do this publish your code here

Dave
 
Last edited:
Upvote 0
My code is below. Label1 is changed via another userform input. Instead of doing this enabled stuff though... I would like to use the locked property for my command buttons. I would also like to exclude a few command buttons from becoming locked.

Code:
Private Sub Label1_Change()


Dim ctrl As Control


If InStr(Me.Label1.Caption, "Signed in as") > 0 Then
    
    For Each ctrl In UserForm1.Controls
        ctrl.Enabled = True
    Next
    
    Set ctrl = Nothing
    
Else
    
    For Each ctrl In UserForm1.Controls
        ctrl.Enabled = False
    Next
    
    Set ctrl = Nothing


End If


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,627
Messages
6,173,417
Members
452,514
Latest member
cjkelly15

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