I have a UserForm with six groups of textboxes representing teams. For each team, a textbox holds "Team Name", "Coach's Name", "Number of Players", "Wins", "Losses".
What I want to do is loop through each group, like:
For myTeams = 1 to 6
TextBox(myTeams).Value = "Lakers"
TextBox(myTeams + 1).Value = "Phil Jackson"
TextBox(myTeams + 2).Value = "15"
TextBox(myTeams + 3).Value = "52"
TextBox(myTeams + 4).Value = "30"
Next myTeams
Unfortunately, this doesn't work. Neither does:
UserForm1.TextBoxes("TextBox" & myTeams).Value
UserForm1.Objects("TextBox" & myTeams).Value
What should my syntax be here? I have read some forum stuff here about looping through all collections, but I need to be more specific because each textbox is going to take a different type of value from names to numbers, etc.
For example, I need to do something along the lines of if textbox(team + 3) > 41 then <something> as in if the team has a greater than 50% win percentage (basketball has 82 games I think). This doesn't work for all controls or all textboxes, but always works for textbox(team + 3).
Obviously above my code is going to be more detailed as in I am not setting all six to the same thing, but I wanted to illustrate that I need to reference these differently depending on the situation.
Any help would be appreciated. Thanks!
What I want to do is loop through each group, like:
For myTeams = 1 to 6
TextBox(myTeams).Value = "Lakers"
TextBox(myTeams + 1).Value = "Phil Jackson"
TextBox(myTeams + 2).Value = "15"
TextBox(myTeams + 3).Value = "52"
TextBox(myTeams + 4).Value = "30"
Next myTeams
Unfortunately, this doesn't work. Neither does:
UserForm1.TextBoxes("TextBox" & myTeams).Value
UserForm1.Objects("TextBox" & myTeams).Value
What should my syntax be here? I have read some forum stuff here about looping through all collections, but I need to be more specific because each textbox is going to take a different type of value from names to numbers, etc.
For example, I need to do something along the lines of if textbox(team + 3) > 41 then <something> as in if the team has a greater than 50% win percentage (basketball has 82 games I think). This doesn't work for all controls or all textboxes, but always works for textbox(team + 3).
Obviously above my code is going to be more detailed as in I am not setting all six to the same thing, but I wanted to illustrate that I need to reference these differently depending on the situation.
Any help would be appreciated. Thanks!