Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Loop through text boxes on User Form

  1. #1
    Join Date
    16th February 2003
    Location
    Vancouver, B.C., Canada
    Posts
    95

    Loop through text boxes on User Form

    Here's the scenario:

    I have a user form with 15 text boxes named form1.text1, .text2, .text3 etc.
    Values will be transferred to these text boxes, but the number of text boxes that values will be transferred to will vary. I need to create a loop that will increment the name of the text box by 1 each time the loop is run.

    I've tried every imaginable form of set statement, variable, etc. and get different kinds of error statements......"Type mismatch, With stetment not set, etc."

    Here's the loop I need:

    For trsf = 1 to num (a variable indicating the #of times loop will run) step 1
    form1.text1.value = first value
    num = num - 1
    next trsf

    The next time the loop runs, the text box name should be text1+1 or text2, etc., etc. etc., and I can't seem to figure out how to change the name so that it is recognizable as an object in the form.

    Any help would be greatly appreciated.

    Thanks in advance

    Ted.............

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    7th March 2003
    Location
    Essex, England
    Posts
    11,314

    Re: Loop through text boxes on User Form

    Hi,

    Something like this,
    VB:
    Dim trsf As Integer 
     
    For trsf = 1 To 3 
        Me.Controls("Textbox" & trsf).Text = "Value " & trsf 
    Next trsf 
    
    

    Cheers
    Andy


  3. #3
    Join Date
    16th February 2003
    Location
    Vancouver, B.C., Canada
    Posts
    95

    Re: Loop through text boxes on User Form

    THANK YOU ANDY !!!

    Once again you have saved my bacon. I had tried the me.controls statement but forgot to use the brackets. Simple solution and works great.

    Hmmmmmmmmm, now if only I could figure out how to mark this post as solved.

    Ted........

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. User form, programming combo boxes
    By Meg in forum EXCEL HELP
    Replies: 16
    Last Post: February 2nd, 2006, 08:25
  2. Combo Boxes in User Form Duplicating
    By kjrae in forum EXCEL HELP
    Replies: 7
    Last Post: November 13th, 2005, 05:08
  3. Initialise user form with blank combo boxes
    By bobwhosmiles in forum EXCEL HELP
    Replies: 9
    Last Post: November 4th, 2004, 00:48
  4. User Form - Displaying Values in Text Boxes
    By Neal in forum EXCEL HELP
    Replies: 4
    Last Post: May 17th, 2003, 13:28
  5. Replies: 6
    Last Post: April 4th, 2003, 21:23

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
  •  
porno