custom header

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
 
D

Dave Peterson

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
 
G

Guest

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
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top