ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help with Months in header (https://www.excelbanter.com/excel-programming/357194-need-help-months-header.html)

Seonemj

Need help with Months in header
 

Trying to modify a macro to insert the same header and footer in all
worksheets. In the right header, I'd rather have a month instead and
year instead of all the date info. This is the one I'd like to use if
the date could be modified:

Sub InsertHeaderFooter()
' inserts the same header/footer in all worksheets
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Changing header/footer in " & ws.Name
With ws.PageSetup
LeftHeader = "Company name"
CenterHeader = "Page &P of &N"
RightHeader = "Printed &D &Y "
LeftFooter = "Path : " & ActiveWorkbook.Path
CenterFooter = "Workbook name &F"
RightFooter = "Sheet name &A"
End With
Next ws
Set ws = Nothing
Application.StatusBar = False
End Sub

I've tried "&M" and many variations to no avail. Ideas?

Seone


--
Seonemj
------------------------------------------------------------------------
Seonemj's Profile: http://www.excelforum.com/member.php...o&userid=32847
View this thread: http://www.excelforum.com/showthread...hreadid=526598


Tom Ogilvy

Need help with Months in header
 
Use the BeforePrint event to update the Right Header with the information
you want.

--
Regards,
Tom Ogilvy


"Seonemj" wrote in
message ...

Trying to modify a macro to insert the same header and footer in all
worksheets. In the right header, I'd rather have a month instead and
year instead of all the date info. This is the one I'd like to use if
the date could be modified:

Sub InsertHeaderFooter()
' inserts the same header/footer in all worksheets
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
Application.StatusBar = "Changing header/footer in " & ws.Name
With ws.PageSetup
LeftHeader = "Company name"
CenterHeader = "Page &P of &N"
RightHeader = "Printed &D &Y "
LeftFooter = "Path : " & ActiveWorkbook.Path
CenterFooter = "Workbook name &F"
RightFooter = "Sheet name &A"
End With
Next ws
Set ws = Nothing
Application.StatusBar = False
End Sub

I've tried "&M" and many variations to no avail. Ideas?

Seone


--
Seonemj
------------------------------------------------------------------------
Seonemj's Profile:

http://www.excelforum.com/member.php...o&userid=32847
View this thread: http://www.excelforum.com/showthread...hreadid=526598





All times are GMT +1. The time now is 12:20 PM.

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