ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I place Range text into a header? (https://www.excelbanter.com/excel-worksheet-functions/125808-how-do-i-place-range-text-into-header.html)

Brad

How do I place Range text into a header?
 
I am trying to have header and/or footer text update automatically when Range
text is changed.

Gord Dibben

How do I place Range text into a header?
 
Brad

Must be done programatically via VBA.

Sub CellInHeader()
With ActiveSheet
.PageSetup.CenterHeader = .Range("A1").Value
End With
End Sub

Or use a BeforePrint rountine.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
.PageSetup.CenterHeader = .Range("A1").Value
End With
End Sub

First macro goes into a General module.

Second goes into the Thisworkbook module.


Gord Dibben MS Excel MVP

On Thu, 11 Jan 2007 13:16:00 -0800, Brad wrote:

I am trying to have header and/or footer text update automatically when Range
text is changed.




All times are GMT +1. The time now is 12:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com