I'm making a user form with multiple checkboxes. I'd like to have a text box pop up only if the checkbox is checked. Is that possible?
I'm making a user form with multiple checkboxes. I'd like to have a text box pop up only if the checkbox is checked. Is that possible?
Hi Alicia,
See the attached with some simple code that does what I think you want.
CheckBox show TextBox if clicked.xlsm![]()
Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.TextBox1.Visible = False Else Me.TextBox1.Visible = True End If End Sub
One test is worth a thousand opinions.
Click the * Add Reputation below to say thanks.
Thanks
* for you both![]()
OMG nevermind. I forgot to change Visible to False
Probable just use the value of the checkbox,
Or even![]()
Private Sub CheckBox1_Click() x = Me.CheckBox1.Value Me.TextBox1.Visible = x End Sub
![]()
Private Sub CheckBox1_Click() Me.TextBox1.Visible = Me.CheckBox1.Value End Sub
I've used all 3 of these and they all work, however, when the user form opens all of the text fields are visible. Only once the box is checked and then unchecked the text field becomes hidden. How can I adjust this to hide the text fields when the user form opens?
In initialize code
etc![]()
Me.TextBox1.Visible = False Me.TextBox2.Visible = False Me.TextBox3.Visible = False
OR
![]()
Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is msforms.TextBox Then ctrl.Visible = False End If Next
Last edited by nigelog; 09-20-2017 at 09:33 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks