View Single Post
  #2   Report Post  
Andy Brown
 
Posts: n/a
Default

"DaveM" wrote in message
...
Ideally I want to add to the print area macro I have written so this

hiding
of unwanted rows happens automatically rather than have to manually hide
using filters or whatever. (As we have 29 classes and 500 students a

manual
system is a bit onerous).


With those numbers, you could do with a routine that loops through a class
list. Everything that follows assumes you have labels in row 1.

Say your class list is in columns H and I (Class #/Teacher). With your
register table in columns A - D (Name/Class #/Present/Re-enrolled?),

Sub Print_Regs()
Range("H2").Select 'go to 1st # in Class # list

Do Until ActiveCell = ""

For Each Cell In Range("A2", Range("A65536").End(xlUp))
If Cell.Offset(0, 1) < ActiveCell Then 'check Class #
Cell.EntireRow.Hidden = True
ElseIf Cell.Offset(0, 3) < "Yes" Then 'check re-enrolled
Cell.EntireRow.Hidden = True
Else
Cell.EntireRow.Hidden = False
End If
Next Cell

ActiveWindow.SelectedSheets.PrintOut Copies:=1
Cells.EntireRow.Hidden = False
ActiveCell.Offset(1, 0).Select 'go to next # in Class # list
Loop

Cells.EntireRow.Hidden = False

End Sub

At the "SelectedSheets.PrintOut" stage you might want to work in other
stuff, eg: set header as Class #, set footer as date, etc.

HTH,
Andy