Reputation: 47
I am using a form with two combo-boxes and a button. I want button to be disabled initially and it should enable only when the user selects a valid value in both the combo-boxes.
I tried to disable the button using the form initialize sub-routine but the button appears to be active. What can be the issue? Also how to enable the button using if conditions?
Private Sub UserForm1_Initialize()
Me.Shapes("ButtonName1").ControlFormat.Enabled = False
ActiveSheet.Shapes("ButtonName1").Font.ColorIndex = 16
End Sub
Upvotes: 0
Views: 187
Reputation: 12113
You made a couple of mistakes in your code.
UserForm1_Initialize
should be UserForm_Initialize
Userform.ButtonName1
to access the properties of your button TextFrame.Characters.Font.ColorIndex
to access the text on a button on the worksheet Private Sub UserForm_Initialize()
UserForm1.ButtonName1.Enabled = False
ActiveSheet.Shapes("ButtonName1").TextFrame.Characters.Font.ColorIndex = 16
End Sub
Upvotes: 1