ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Date formula for footer/header (https://www.excelbanter.com/excel-discussion-misc-queries/53754-date-formula-footer-header.html)

Kurtlee

Date formula for footer/header
 
I'm pretty new to excel. My question is, is there a way to have the date in
the header/footer roll back one day? And if it is a Monday, can it roll back
to Friday? If I use a cell for the date it throws the entire format for a
loop and I end up having an entire row with just 1 thing in it. Any help
would be greatly appreciated.

Bob Phillips

Date formula for footer/header
 
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim dte As Date

dte = Date - 1
If Weekday(dte) = 1 Then
dte = dte - 1
End If
If Weekday(dte) = 7 Then
dte = dte - 1
End If
With ActiveSheet.PageSetup
.LeftFooter = Format(dte, "dd mmm yyyy")
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Kurtlee" wrote in message
...
I'm pretty new to excel. My question is, is there a way to have the date

in
the header/footer roll back one day? And if it is a Monday, can it roll

back
to Friday? If I use a cell for the date it throws the entire format for a
loop and I end up having an entire row with just 1 thing in it. Any help
would be greatly appreciated.





All times are GMT +1. The time now is 01:02 PM.

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