Hi people!
I have a table with the following:
- Rows starting from A2 until whatever amount of kids that are in a class (variable)
- Questions ranging from D1 until "x"1 with x being whatever value is in cell AL30
I dynamically populate a userform with the names of the kids on the left, and after every name an amount textboxes corresponding with the number in cell AL30. This lets me score every question of a test for every kid in a class.
So far... so good. Now the read out part. I want the values that I put in the textboxes (numbers of course, since they are points) to be put in an array on whatever sheet.
This is my code so far, but I am kinda stuck.
Private Sub CommandButton1_Click()
Dim ct As Control, t As Long
t = Sheets("Sheet1").Range("AL30").Value
ReDim arr(0 To (Range("A" & Rows.Count).End(xlUp).Row - 1), 0 To (t - 1))
With Sheets("Scores")
For Each ct In Controls
If TypeName(ct) = "TextBox" Then
Do Until .Cells(n + 1, 1) <> ""
For j = 0 To t - 1
arr(n, j) = ""
Next j
n = n + 1
j = 0
Loop
arr(n, i) = TextBox.Value
i = i + 1
If i = t Then
n = n + 1
i = 0
End If
End If
Next ct
.Range("B1").Resize(n, t).Value = arr
End With
Me.Hide
End Sub
Ofcourse the length of the array has to correspond to how many questions there are (in Cell AL30) and the height has to correspond to how many kids there are in clas (The count from A2 until the last filled cell in column A).
I am unsure what to do with the arr() statements
Also... I am unsure to what will happend with the array when there are empty textboxes and the "save" button is clicked. I can imagine a user putting in results of kids and having to close halfway...
Any thoughts?
Thanks!
Bookmarks