custom header

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

Guest

I would like to know how to set up a custom header which shows the data in a
perticular cell (i.e. - C9 shows the number 100, so I want the header in all
the pages,except the first, to show "100".

Thank you
 
One way is to use a macro.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim myHeaderStr As String
Dim iCtr As Long

myHeaderStr = Worksheets("sheet3").Range("C9").Value

For iCtr = 2 To Worksheets.Count
Worksheets(iCtr).PageSetup.LeftHeader = myHeaderStr
Next iCtr

End Sub

(I used c9 on sheet3 (you didn't say which sheet to use).)

This code goes in the ThisWorkbook module.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
I don't know what I am doing wrong. I followed the directions for copying
and pasting a macro from the site you recommended....but I can't get it to
work.

My workbook is named "book1", the sheet is named "Order form" and the cell
is "c9".

What do you suggest for getting this to work?

Thank you
 
Make sure you pasted that workbook_beforeprint routine into the ThisWorkbook
module.

If you've verified that the code is there, what happens when you hit
File|PrintPreview?

And you may want to post the code you used.
 
Back
Top