Formula in a header

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

Guest

Can you put a formula in a header? I would like to get the prior months end
day (7/31/07). in a header? Can this be done? How?

Thanks,
Donna
 
One way:

Put this in your workbook's ThisWorkbook Code module (if you're not
familiar with macros, see

http://www.mvps.org/dmcritchie/excel/getstarted.htm
)

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim ws As Worksheet
Dim d As Date
d = Date
For Each ws In ActiveWindow.SelectedSheets
ws.PageSetup.LeftHeader = Format(DateSerial(Year(d), _
Month(d), 0), "dd mmm yyyy")
Next ws
End Sub

Substitute CenterHeader or RightHeader, and your favorite date format to
suit.
 

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

Back
Top