Loop Through A Series of TextBoxes in a Userform

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,570
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a userform with a series of 8 textboxes each holding a unique value.
I am looking for code that will step through each one of these 8 boxes to gather the value so that I can use that value in further code.

I am not sure how to set up a loop referring to the 8 different textbox names.

I'm sorry if I'm vague with my details. Please let me know if I've forgotten some critical information / expectations if you're willing to help.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi Norie, thanks for your reply.

Unsure if this is what you were looking for in an answer ... cu2_en, cu3_en, cu4_en, cu5_en, cu6_en, wprk1_en and wbvd1_en. All hold a 5 digit number.
Once I get the number, each one will be applied to it's own lookup routines to fill cells in a worksheet.

If there is a solution I will have to similar scenario in another worksheet, so I hope there is a solution.
 
Upvote 0
You could try something like this.
Code:
Dim I As Long

    arrCtrls = Array("cu2_en", "cu3_en", "cu4_en", "cu5_en", "cu6_en", "wprk1_en","wbvd1_en")

    For I = LBound(arrCtrls) To UBound(arrCtrls)
        valLookup = Me.Controls(arrCtrls(I)).Value

        '
        ' do stuff with value from textbox
        '
    Next I
 
Upvote 0
Hello Norie,
My apologies for not acknowledging your help until now. I hadn't had an opportunity to try it out.
It works wonderfully so far!!
I did have to make one minor adjustment. Since the controls were actually labels, i had to change .value to .caption in this line ...
Code:
valLookup = Me.Controls(arrCtrls(I)).Caption
 
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,607
Members
452,660
Latest member
Zatman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top