Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, I'm trying to get my head around how to code a For Loop with changes in the variable name. I have 19 rows of data and I need to populate some text boxs on a user form. I can do this by using 19 lines of code but I'm sure it can be done using a loop? This is what I have now: Me.txtShipWeight1.Value = Worksheets("Calculations").Range("ShipWeighting1") Me.txtShipWeight2.Value = Worksheets("Calculations").Range("ShipWeighting2") Me.txtShipWeight3.Value = Worksheets("Calculations").Range("ShipWeighting3") .... .... etc. The only difference in each line is the text box control name and the named range in the worksheet. Can this be coded in a loop? Thanks for any help you can offer. Cheers -- skuzapo ------------------------------------------------------------------------ skuzapo's Profile: http://www.excelforum.com/member.php...o&userid=27430 View this thread: http://www.excelforum.com/showthread...hreadid=516014 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For i = 1 To 19
Me.Controls("txtShipWeight" & i).Value = _ Worksheets("Calculations").Range("ShipWeighting" & i) Next i -- HTH Bob Phillips (remove nothere from email address if mailing direct) "skuzapo" wrote in message ... Hi, I'm trying to get my head around how to code a For Loop with changes in the variable name. I have 19 rows of data and I need to populate some text boxs on a user form. I can do this by using 19 lines of code but I'm sure it can be done using a loop? This is what I have now: Me.txtShipWeight1.Value = Worksheets("Calculations").Range("ShipWeighting1") Me.txtShipWeight2.Value = Worksheets("Calculations").Range("ShipWeighting2") Me.txtShipWeight3.Value = Worksheets("Calculations").Range("ShipWeighting3") ... ... etc. The only difference in each line is the text box control name and the named range in the worksheet. Can this be coded in a loop? Thanks for any help you can offer. Cheers -- skuzapo ------------------------------------------------------------------------ skuzapo's Profile: http://www.excelforum.com/member.php...o&userid=27430 View this thread: http://www.excelforum.com/showthread...hreadid=516014 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Bob, That's excellent thanks for your help. I'll try that. Cheers -- skuzapo ------------------------------------------------------------------------ skuzapo's Profile: http://www.excelforum.com/member.php...o&userid=27430 View this thread: http://www.excelforum.com/showthread...hreadid=516014 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find loop doesn't loop | Excel Discussion (Misc queries) | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Loop Function unable to loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming |