vba to auto fill day of week and date in left footer of each sheet when you go to print out

slivesay

Board Regular
Joined
Jan 4, 2019
Messages
64
Hello. I am looking for some vba code to add the day of the week to the below wording and to work when printing for all sheets in a workbook.

Currently it says in the footer:

Report Dated: 08/30/2019

Format for wording is: Bahnschrift SemiBold Font, SemiBold Font style and 9 size.

Want it to say:

Report Dated: Friday, 08/30/2019

Or something like that w/ the same format as it is now.

Is this a possibility?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I assume that you are trying to print the current date. Unfortunately, you cannot place formulas in header/footers.
However, we are able to get around this by using VBA, as shown here: https://excelribbon.tips.net/T000559_Using_a_Formula_in_a_Footer.html

The code would look something like this:
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    
    Dim sTemp As String
    Dim ws As Worksheet
    
'   Set wording for date range
    sTemp = Format(Date, "dddd, mm/dd/yyyy")

    For Each ws In Worksheets
        With ws
            .PageSetup.LeftFooter = "&""Bahnschrift SemiBold,SemiBold""&9" & sTemp
        End With
    Next ws
    
End Sub

Note that this code MUST be placed in the "ThisWorkbook" module in order to work automatically when printing.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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