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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,222,195
Messages
6,164,509
Members
451,900
Latest member
lamski

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