Header that auto displays the previous month

Stuck1

Board Regular
Joined
Sep 3, 2009
Messages
73
Hi all,

I want to display the text: "Period Report to: December 2009" on the print out of a report I produce every month. I always publish the report at the start of the following month, so December's report will come out in January and January's in Fenruary, etc.

I know I could change the headers every month, but I always forget to do it. I have this code, but don;t know how to get it to say the previous month instead of today's date:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.RightHeader = "& Period Report to: " & Format(Now, "DD-MMM-YY")
End With
End Sub

Any help would be great.

Thanks,

Lee
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try this:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet.PageSetup
.RightHeader = "& Period Report to: " & Format(DateAdd("m", -1, Date), "mmmm")
End With
End Sub
 
Upvote 0
or
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    ActiveSheet.PageSetup.RightHeader = "& Period Report to: " & Format(Date-28, "mmmm yyyy")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top