help with header

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

how can I display the contents of a cell in the header of a spreadsheet?
Example
in cell C3 is the date that was imported from an external database. In
the page setup, I am entering the following text.
Trend Data for
at the end of that line I want to display the date that is in cell C3
How can I do this?
Thanks for any help.
 
Hi Peter
there is no way to directly insert a formula into the header/footer
definition. You have to use the workbook event Before_print to insert
cell values into the header. e.g.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "Trend Data for: " &
format(range("C3").value,"mm/dd/yyyy")
End Sub

Put this into the workbook code module. The cell value of C3 will be
inserted.
HTH
Frank
 
Thanks for the help.

Frank said:
Hi Peter
there is no way to directly insert a formula into the header/footer
definition. You have to use the workbook event Before_print to insert
cell values into the header. e.g.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "Trend Data for: " &
format(range("C3").value,"mm/dd/yyyy")
End Sub

Put this into the workbook code module. The cell value of C3 will be
inserted.
HTH
Frank
 
Back
Top