add procedure to prevent filling data on userform when run based on color label

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi
is there any procedure to prevent filling data on userform based on color label ?
what I want if I have lable1 is hidden or is not hidden but not yellow color then should not show any thing on usefrom when run it ( this means should not fill listbox or combobox or any tool on userfrom when run it if theses conditions are not verified ) , if the Label1 is not hidden and yellow color then should show the data on userform .
I want adding this procedure before my code in userform initialize() (this kind of protection).
thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Without seeing what code you have...

I'd put code in after whatever code sets the code to yellow and say:
VBA Code:
With UserForm1
    .TextBox1.Locked = True
    .ComboBox1.Locked = True
    'etc.
End With
and unlock them where you change it to not yellow.

If you want to lock everything down
VBA Code:
Dim ctrl As Control
For Each ctrl In UserForm1.Controls
Debug.Print ctrl.Name, TypeName(ctrl)
    If Not TypeName(ctrl) = "Label" Then ctrl.Locked = True
Next
Set ctrl = Nothing
 
Upvote 0
Without seeing what code you have...
thanks just add before the whole code . if the condition is not met then should n't fill tools and when codition is met then should keep to run the macro and fill the data based on my code
by the way I don't see anything about yellow lable in the code even if that doesn't work for me when run the userform . all of things are filled .
 
Upvote 0

Forum statistics

Threads
1,215,221
Messages
6,123,701
Members
449,117
Latest member
Aaagu

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