Consulting

Results 1 to 6 of 6

Thread: Similarly named textboxes - loop

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location

    Similarly named textboxes - loop

    Hi all,

    is ther ea specific way to loop thru a group of textboxes with a similar name? ie txtAcct1, txtAcct2, txtAcct3.

    TIA

  2. #2
    Depends what your doing, and how your code looks like... But I suppose something like this would work.

    x = 1
    
    txtAcct & x
    
    x = x + 1
    
    Loop
    This isn't a complete code, this is just an idea.

  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location
    Cheers for the reply I tried that already and it errored out. I'm trying to put data into the textboxes from an array. Couldnt find any examples, so I'm trying to step thru the process.

  4. #4
    How about this?

    x = 1
    Do Until x = 4
    
    
    UserForm1.Controls.Item("TextBox" & x).Value = Range("A" & x).Value
    x = x + 1
    Loop
    Screenshots




  5. #5
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location
    oh that looks excellent. I'll try that out! Cheers for that!!!!

  6. #6
    VBAX Regular
    Joined
    Feb 2007
    Posts
    35
    Location
    ashley - THANK YOU SO MUCH!!!!! works a treat!!!!!! that one bit of code sorted a lot for me. CHEERS!

Posting Permissions

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