Reputation: 37
I am using a userform that act as a scorecard for audits. Each textbox on the form is a score for each item on the list. What I want to do is when the user hits submit, the code loops through the range of cells where those scores go and input the score in them. I have the following:
For i = 6 To 14 ' number of cells to loop through
For j = 1 To 9 ' number of textboxes in the userform
Cells(j, 3).Value = Me.Controls("score" & i).Value 'Textboxes named as such: score1, score2
Next j
Next i
which inputs the same score in each cell (the value of the last textbox). While I can see why it is doing this, I am unsure of how to make it move to the next cell for the next score without fully looping through the 2nd for set first. Any insight into how to make that happen would be much appreciated
Upvotes: 0
Views: 561
Reputation: 166126
You only need one loop:
For i = 6 To 14
Cells(i, 3).Value = Me.Controls("score" & (i-5)).Value
Next i
(unsure exactly where your cells are, but you get the idea)
Upvotes: 2