Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Userform controls -looping (2000)

    I am looking for the collection of Textboxes on a UserForm so I can loop thru them as follows:

    Dim TB as TextBox
    Dim i as Integer
    i=1
    For each TB in Me.TextBoxes
    TB.Text =Cells(1,i)
    i=i+1
    Next TB

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Userform controls -looping (2000)

    There is no TextBoxes collection, only a Controls collection. Try this:

    Dim ctl As Control
    Dim i As Long
    For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Then
    i = i + 1
    ctl.Text = Cells(1, i)
    End If
    Next ctl

Posting Permissions

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