looping through userform controls

switters_aka

Board Regular
Joined
Oct 26, 2010
Messages
118
I am trying to loop through userform textbox controls to populate an array and want to use the loop variable in the code e.g.

Code:
for i=1 to 6
myarray(i,1)=userform2.mytextbox(i).value
myarray(i,2)=userform2.histextbox(i).value
myarray(i,3)=userform2.hertextbox(i).value
next i

This doesn't work though and I was wondering if anyone else had come across this issue before and found a solution. Thanks in advance for your help.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Why do you have "textbox(i)"? What are you trying to extract, to place into your array? the ith character of the text in "textbox"?

and how is your array defined?
 
Upvote 0
just after hitting the send button I found the solution in another forum

Code:
userform2.controls("textboxname" & i).value

Thanks anyway for the response. :)
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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