Hi I have a UserForm with around 140 TextBoxes and I want them all to have the property Visible = False. To avoid me the labour of doing this one by one, can I do this in a faster, easier way?
Hi I have a UserForm with around 140 TextBoxes and I want them all to have the property Visible = False. To avoid me the labour of doing this one by one, can I do this in a faster, easier way?
Last edited by Michael Island; 06-14-2020 at 03:28 PM.
![]()
For Each ct In Me.Controls If TypeName(ct) = "TextBox" Then ct.Visible = False Next ct
This will only do the TextBoxes on that UserForm right?
Can you try anyway?
ok will not save it until it works then.![]()
It gave me Error 'Invalid Outside Procedure'
Last edited by Michael Island; 06-13-2020 at 12:10 PM.
Then place the file with how you applied it.
In addition to Vraag en antwoord's request in Message #7, can you also tell us when you need this functionality... only when the UserForm first displays or do you need to make the TextBoxes invisible at some point later on after the UserForm has been up for a while?
I assume you did not put it in a procedure \ subIt gave me Error 'Invalid Outside Procedure'
![]()
Private Sub CommandButton1_Click() For Each ct In Me.Controls If TypeName(ct) = "TextBox" Then ct.Visible = False Next ct End Sub
Last edited by Sintek; 06-14-2020 at 05:19 AM.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
No need as I figured out how to do it. As I go through the form I know which TextBoxes I need, so once I have prepared the Subs I will have all the IextBoxes I need to make Enabled = False and Visible = False. So I will create a Sub like so:
Then I run it before I make UserForm2 appear like:![]()
Sub EntryField_DisEnabler() UserForm2.TextBox8.Enabled = False UserForm2.TextBox8.Visible = False etc... End Sub
EntryField_DisEnabler
UserForm2.Show
This should work fine right?![]()
If this is the only time you need to set all (or most) of the TextBoxes to Enabled equal False and Visible equal False, then you do not need code to do this. Select (Shift click) all of the TextBoxes on the UserForm that you want to have this setting when the UserForm first appears, then look at the Properties Window and change the Enabled property to False and then the Visible property to False. Now unselect those TextBoxes (just click a blank section of the UserForm) and then save the workbook. Now when you show that UserForm, those TextBoxes will automatically be disabled and invisible.
sintek can we make that Sub only affect UserForm2 ? Run from UserForm1 ? And to also Enabled = False for each TextBox ?
Last edited by Michael Island; 06-14-2020 at 06:45 AM.
May only Sintek respond?
![]()
Sub EntryField_DisEnabler() For Each ct In Userform2.Controls If TypeName(ct) = "TextBox" Then ct.Visible = False ct.Enabled = False End If Next ct End Sub
This works well for my needs![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks