For a project I've been reading data into a file and manipulating it. Without pasting all the pages, the student ID variable represents a random number from 1-15, and then I think that the best way to sort it into groups of three is to assign each of the arrays with a number from 1-3. The groupsizes are variable based on user input however, as are the number in the class (Up to 30), and so I'm finding it difficult to place the code in a more optimised format than this-
For i = 1 To TotalClassSize
If pupil(i).StudentID <= Groupsizes(1) Then
pupil(i).AssignedGroup = 1
End If
If pupil(i).StudentID <= Groupsizes(2) + Groupsizes(1) And _
pupil(i).StudentID > Groupsizes(1) Then
pupil(i).AssignedGroup = 2
End If
If pupil(i).StudentID <= Groupsizes(3) + Groupsizes(2) + Groupsizes(1) And _
pupil(i).StudentID > Groupsizes(2) + Groupsizes(1) Then
pupil(i).AssignedGroup = 3
End If
Next
If anyone could give me a hand on a simple way to optimise this better, that'd be great :D (First time posting, so if I've missed anything wrong or put this in the wrong place etc just let me know)
For i = 1 To TotalClassSize
If pupil(i).StudentID <= Groupsizes(1) Then
pupil(i).AssignedGroup = 1
End If
If pupil(i).StudentID <= Groupsizes(2) + Groupsizes(1) And _
pupil(i).StudentID > Groupsizes(1) Then
pupil(i).AssignedGroup = 2
End If
If pupil(i).StudentID <= Groupsizes(3) + Groupsizes(2) + Groupsizes(1) And _
pupil(i).StudentID > Groupsizes(2) + Groupsizes(1) Then
pupil(i).AssignedGroup = 3
End If
Next
If anyone could give me a hand on a simple way to optimise this better, that'd be great :D (First time posting, so if I've missed anything wrong or put this in the wrong place etc just let me know)