+ Reply to Thread
Results 1 to 3 of 3

Looping through userform textboxes using variables

  1. #1
    Registered User
    Join Date
    MS-Off Ver
    Excel 2010

    Question Looping through userform textboxes using variables

    Scenario: Userform with 5 contact fields at the top made from textboxes (First, Last, Title, Phone, Email,) that I attempting to populate a 5x6 table below that I have created using textboxes (contact1,2,3...) on the same userform. I have a command button I would like to use to populate a contact row and clear the contact fields each time I fill the contact fields and press the button (fill contact fields, press button, populate row 1, fill contact fields, press button, populate row 2.... ). I think I need to incorporate a "control" variable, but I have been writing code now for 14hrs and my brain is not working at peak efficiency. Any help is greatly appreciated!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    The Netherlands
    MS-Off Ver
    Office 2016

    Re: Looping through userform textboxes using variables

    Hi, welcome to the forum
    You can address a Control by dimensioning as Control

    Me.Coontrols(Ctrl.Name & i (or j) or any numebr).Value (for textboxes and ComboBoxes), .Caption for OptionButtons, CheckBoxes and Labels

    Hope this helps (a little)

    Dim Ctrl As Control
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru
    Join Date
    MS-Off Ver
    Excel 2003

    Re: Looping through userform textboxes using variables

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread


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