A few codes I have tried so far but have not worked are:
Private Sub UserForm_Initialize()
Dim i As Integer
ListBox1.Clear
i = 1
For i = 7 To ActiveWorkbook.Sheets.Count
Sheets(i).Select
If Range("C7").Text = "elective class: " Then
ListBox1.AddItem Sheets(i).Name
ElseIf Range("C7").Text = "" Then
ListBox2.AddItem Sheets(i).Name
End If
Next
i = 0
End Sub
Dim sSheet
For Each sSheet In Sheets
If LCase(sSheet.Range("C7").Value) = "elective class: " Then
ListBox1.AddItem sSheet.Name
ElseIf LCase(sSheet.Range("C7").Value) = "" Then
ListBox2.AddItem sSheet.Name
End If
Next sSheet
Also have done a couple variations of the second of the two codes including counters and an index to start the population from the seventh worksheets along but I had no luck.
I am guessing I have made a basic error or if there is a completely different formula which would work better, then I am more than happy with that also. I'll probably turn screen updating off for both of these too.
For the printing which I haven't had a chance to test yet as I haven't populated both listboxes this is the code I have put in:
Dim iloop As Integer
For iloop = 1 To ListBox1.ListCount
If ListBox1.Selected(iloop - 1) = True Then
Sheets(ListBox1.List(iloop - 1, 0)).PrintOut
ListBox1.Selected(iloop - 1) = False Then
For iloop = 1 To ListBox2.ListCount
If ListBox2.Selected(iloop - 1) = True Then
Sheets(ListBox2.List(iloop - 1, 0)).PrintOut
ListBox2.Selected(iloop - 1) = False
EndIf
Next
I'm pretty sure its wrong...
Many thanks,
Tom
Bookmarks