+ Reply to Thread
Results 1 to 4 of 4

Looping through userform textboxs to make them visible

Hybrid View

  1. #1
    Registered User
    Join Date
    01-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Looping through userform textboxs to make them visible

    Hey, gang--
    Right to the problem.

    I am working in a userform. This is how I'd like it to run:

    The user is asked to input the number of intersections. That number will be used to either add textboxes and corresponding labels or make visible pre-existing textboxes and labels hidden on the userform.

    Originally I wanted to add the textboxes, but since I haven't dipped my toes in code for quite some time, I decided it would be easier to make pre-existing textboxes visible. Now I don't know how to do either. It doesn't seem like there is a way to have a control variable, and all the research I've been doing includes a For Each Loop which ignores my counter number. I'd like to start from scratch on this one, so if any of you can get me started in the right direction, I'd greatly appreciate it!

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Looping through userform textboxs to make them visible

    If you have used a naming convention then you can use something like this

    Dim i as integer 
    For i = 1 to somevalue
       Me.controls("textbox" & i).visible = true
    Next i
    If that is what you meant?

  3. #3
    Registered User
    Join Date
    01-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Looping through userform textboxs to make them visible

    Hey, OnError! I'm thinking that's what I'll try. I've named the textboxes "Int1", "Int2", etc and the labels as "IntLab1", "IntLab2", etc. In the above code would the part in the parenthesis in quotes ("textbox") be part of my naming convention? For example:

    Me.controls("Int" & i).visible = true

    Thanks for your time, OnError!

  4. #4
    Registered User
    Join Date
    01-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Looping through userform textboxs to make them visible

    Life saver, OnError! It worked perfectly! Thank you for saving me tearing my hair out!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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