+ Reply to Thread
Results 1 to 15 of 15

Can I make all TextBoxes on a particular UserForm Visible = False?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Can I make all TextBoxes on a particular UserForm Visible = False?

    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.

  2. #2
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    For Each ct In Me.Controls
        If TypeName(ct) = "TextBox" Then ct.Visible = False
      Next ct

  3. #3
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    This will only do the TextBoxes on that UserForm right?

  4. #4
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    Can you try anyway?

  5. #5
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    ok will not save it until it works then.

  6. #6
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    It gave me Error 'Invalid Outside Procedure'
    Last edited by Michael Island; 06-13-2020 at 12:10 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    Then place the file with how you applied it.

  8. #8
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,466

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    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?

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    It gave me Error 'Invalid Outside Procedure'
    I assume you did not put it in a procedure \ sub

    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!!!

  10. #10
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    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:

    Sub EntryField_DisEnabler()
    UserForm2.TextBox8.Enabled = False
    UserForm2.TextBox8.Visible = False
    etc...
    End Sub
    Then I run it before I make UserForm2 appear like:

    EntryField_DisEnabler
    UserForm2.Show

    This should work fine right?

  11. #11
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,466

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    Quote Originally Posted by Michael Island View Post
    Then I run it before I make UserForm2 appear like:

    EntryField_DisEnabler
    UserForm2.Show
    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.

  12. #12
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    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.

  13. #13
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    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

  14. #14
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    This works well for my needs

  15. #15
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,466

    Re: Can I make all TextBoxes on a particular UserForm Visible = False?

    Quote Originally Posted by Michael Island View Post
    This works well for my needs
    I am curious... what works well, the coded or non-coded solution (we cannot tell who you are replying to)?
    Last edited by Rick Rothstein; 06-14-2020 at 05:02 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Make a userform visible only when a particular cell is clicked
    By Nick Vittum in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-12-2020, 01:04 PM
  2. [SOLVED] Make multiple textboxes visible at once
    By Jaron_t in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-31-2012, 09:41 PM
  3. [SOLVED] How to make textbox visible true/false
    By fremarco in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2012, 11:40 PM
  4. Write If/And statement for userform textboxes that are only visible
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-15-2012, 11:10 AM
  5. UserForm Knowledge needed to make TextBoxes in both places as numbers
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-20-2012, 11:34 AM
  6. If TextBox has value set visible other TextBoxes, if not set false
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-02-2011, 02:53 PM
  7. Make calendar visible and invisible in userform
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-24-2009, 05:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1