PDA

View Full Version : [SOLVED] Similarly named textboxes - loop



ukyank
12-26-2013, 02:48 PM
Hi all,

is ther ea specific way to loop thru a group of textboxes with a similar name? ie txtAcct1, txtAcct2, txtAcct3.

TIA

ashleyuk1984
12-26-2013, 03:01 PM
Depends what your doing, and how your code looks like... But I suppose something like this would work.


x = 1

txtAcct & x

x = x + 1

Loop

This isn't a complete code, this is just an idea.

ukyank
12-26-2013, 03:29 PM
Cheers for the reply I tried that already and it errored out. I'm trying to put data into the textboxes from an array. Couldnt find any examples, so I'm trying to step thru the process.

ashleyuk1984
12-26-2013, 03:53 PM
How about this?


x = 1
Do Until x = 4


UserForm1.Controls.Item("TextBox" & x).Value = Range("A" & x).Value
x = x + 1
Loop


Screenshots

http://www.ultraimg.com/images/SHVBC.png
http://www.ultraimg.com/images/ZdSTA.png
http://www.ultraimg.com/images/vRfD.png

ukyank
12-26-2013, 04:15 PM
oh that looks excellent. I'll try that out! Cheers for that!!!!

ukyank
12-26-2013, 04:43 PM
ashley - THANK YOU SO MUCH!!!!! works a treat!!!!!! that one bit of code sorted a lot for me. CHEERS!