Loop for Textbox Values

mosiki

Board Regular
Joined
Oct 29, 2008
Messages
175
Hi

I have userform containing 4 tabs (Pages). On Page 1 there are 31 textboxes each named Player1, Player 2....Player31.

On page 2 there are also 31 textboxes each named Player2_1, Player2_2....Player2_31.

I can write code so that the textboxes on page 2 have the same text as the textboxes on page 1, however it is long winded, example below:

Player2_1.Text = Player1.Text
Player2_2.Text = Player2.Text....and so on for each of the 31 text boxes.

QU. Is there a particular way of using a For....Next loop to shorten the amount of code.

Eg. Dim i as Integer
For i = 1 to 31
Player2_i.Text = Playeri.Text
Next i

The above doesn't work obviously or I wouldn't be asking. Any ideas ?

Thanks

Mosiki
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Something limke the below should work

Dim i As Integer
For i = 1 To 31
Me.Controls("Player2_" & i).Text = Me.Controls("Player" & i).Text
Next i


Cheers
GB
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

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