View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default print column labels with one row of data at a time.

Sub PrintData()
Dim sh As Worksheet, rng As Range
Dim numcols As Long
Dim cell As Range
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
Set rng = sh.Range(sh.Cells(3, 1), _
sh.Cells(3, 1).End(xlDown))
numcols = sh.Cells(1, 256).End(xlToLeft).Column
sh.PageSetup.PrintArea = rng.Resize(, _
numcols).Address(1, 1, xlA1, True)
sh.PageSetup.PrintTitleRows = _
sh.Rows(1).Resize(2).Address(1, 1, xlA1, True)
sh.PageSetup.Orientation = xlLandscape ' or xlPortrait
rng.EntireRow.Hidden = True
For Each cell In rng
If cell.Row < 3 Then
cell.Offset(-1, 0).EntireRow.Hidden = True
End If
cell.EntireRow.Hidden = False
sh.PrintPreview
Next
rng.EntireRow.Hidden = False
Next
End Sub

--
Regards,
Tom Ogilvy



"Barb Reinhardt" wrote in message
...
You may want to write a macro to do this. I'm new to VB so am
cross-posting this in microsoft.public.excel.programming.


"gooba937" wrote in message
...
I am a teacher. I have created my gradebook in excel. (I don't have
access). I have 7 worksheets (one for each class that I teach). The
worksheets are not exactly the same.

I would like to be able to print out the top two rows (column labels)

with
each students data (row). This way the student can see row 1 (name of
assignment), row 2 (points), their row (their personal data for each
assignment).

Any help??