using text from a cell in header

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anybody have a clue if and how I can use the text from a cell in the first line of each page in the header

For example
Page 1: A
Page 2: A5
Page 3: A10
etc

Thanks in adance

Emiel (Holland)
 
Look at the rows to repeat at the top setting in the the 3rd tab of the page
setup dialog.

If you want to use a different cell at the top of each page in a worksheets,
then you will have to print each page separately and either put the value on
the page or change the value in the rows to repeat location.

--
Regards,
Tom Ogilvy

Emiel said:
Does anybody have a clue if and how I can use the text from a cell in the
first line of each page in the header?
 
One way:

Put this in theThisWorkbook code module.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim vHeaderCells As Variant
Dim wsSheet As Worksheet
Dim i As Long
Application.EnableEvents = False
Cancel = True
For Each wsSheet In ActiveWindow.SelectedSheets
With wsSheet
If .Name = "Sheet1" Then
vHeaderCells = Array("A1", "A50", "A100")
For i = 1 To UBound(vHeaderCells) + 1
.PageSetup.LeftHeader = _
.Range(vHeaderCells(i - 1)).Value
.PrintOut from:=i, To:=i, preview:=True
Next i
Else
.PrintOut preview:=True
End If
End With
Next wsSheet
Application.EnableEvents = True
End Sub

Change "Sheet1" to suit.

Emiel said:
Does anybody have a clue if and how I can use the text from a cell in the
first line of each page in the header?

For example:
Page 1: A1
Page 2: A50
Page 3: A100
etc.

Thanks in adance.

Emiel (Holland)

0.
 
Back
Top