+ Reply to Thread
Results 1 to 4 of 4

Looping thru Textboxes

Hybrid View

  1. #1
    Registered User
    Join Date
    01-25-2005
    Posts
    2

    Looping thru Textboxes

    Excel VBA newbie ... please be gentle.

    I have a userform with 40 textboxes, however depending upon the value of a given cell - some of these textboxes should be hidden, eg A1="10", textboxes 11-40 should be hidden.

    I need to do something like

    maxTB = range("A1").Value
    for I in maxTB+1 to 40
    textboxI.hidden
    next

    but for the life of me I can't find anything in any forum or helpsite.

    Anyone ?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Zac,

    You almost have it. Not bad for newbie.
    ________________________________________________________________

    Dim MaxTB As Long
    Dim I As Long
    Dim TB As Object


    MaxTB = Range("A1").Value

    For I = MaxTB + 1 To 40

    ' Set Object Variable TB to point to TextBox'n' on the user form
    Set TB = UserForm1.Controls("TextBox" & Trim(Str(I)))

    ' Set the TextBox Visible property to False - Hide it!
    TB.Visible = False

    Next I
    ________________________________________________________________

    Hope this helps,
    Leith Ross

  3. #3
    Registered User
    Join Date
    01-25-2005
    Posts
    2
    Marvellous.

    Thanks a bunch.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hi Zac,

    You're welcome. Keep up the good work!

    Best Wishes,
    Leith Ross

+ 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