Bit of a complicated one and I have no real idea if it can even be done. I have a spreadsheet of students (213 of them) and the classes they take during different periods (i.e. column one is the list of students, then the columns afterwards are Monday P1, Monday P2 and so on). There is a two week timetable too.
Some periods don't have any data in, because they have a free period, but I need to randomly assign two specific study periods (using an ICT suite) per student.
However, there can only be a certain number of kids in the study period due to the lack of computers! I essentially want to allocate two study sessions per row (i.e. per student), but without having 86 students attending one study session (for example), and only four in the second. I fear that there are too many variables and I'll have to do it the old fashioned slow way.
Any ideas how it could be done?
I did try the following:
Sub ss()
Dim MyRange As Range
Dim MyColumn As Long
Dim MyMin As Long
Dim MyMax As Long
Dim MySwitch As Long
MyMin = 4
MyMax = 63
MyVar = MyMin
MySwitch = 0
Do Until MyVar = MyMaxSet MyRange = ActiveWorkbook.Worksheets("Sheet1").Range(Cells("A2", MyVar), Cells("A214", MyVar))
For Each cell In MyRange.Cells
Select Case MySwitch
Case 0
If cell.Value = "" Then
cell.Value = "Study session 1"
MySwitch = MySwitch + 1
End If
Case 1
If cell.Value = "" Then
cell.Value = "Study session 2"
MySwitch = MySwitch - 1
End If
Case Else
MsgBox "An error has occurred"
End Select
Next
MyVar = MyVar + 1
Loop
End Sub
but this doesn't work (my first attempt at a macro!). I've attached the file as I'm not sure if I've made sense!
Bookmarks