View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default using text from a cell in 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.

In article ,
"Emiel" wrote:

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.