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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,222,315
Messages
6,165,302
Members
451,950
Latest member
WH2000

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