ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formula in a header (https://www.excelbanter.com/excel-discussion-misc-queries/152898-formula-header.html)

Donna S

Formula in a header
 
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

JE McGimpsey

Formula in a header
 
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.


In article ,
Donna S wrote:

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?



All times are GMT +1. The time now is 10:46 PM.

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