Formatting Date to show Month in Customized Header - Can it

eliW

Well-known Member
Joined
Mar 2, 2002
Messages
1,931
Hi all,
I need to show Month instead of
Date in the header of my prints. Can Date be formatted to show Month?

Much appreciation to any hint.

Eli
This message was edited by eliW on 2002-10-02 08:42
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

JetPhoenix

New Member
Joined
Jun 18, 2002
Messages
11
Most def.

try this format...

ls_date = Format(ls_date, "dd mmmm yyyy")

works fine for me in my add-in.
 

eliW

Well-known Member
Joined
Mar 2, 2002
Messages
1,931
On 2002-10-02 06:50, JetPhoenix wrote:
Most def.

try this format...

ls_date = Format(ls_date, "dd mmmm yyyy")

works fine for me in my add-in.
Thank you but can you give me a more detailed explenation?

I know how to format Date to show the month only: it's "mmm".
What I need is to do it in the Page Setup - Customized Header -
Date button.

Eli
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I don't know a way to do it without VBA.

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    With ActiveSheet.PageSetup
        .LeftHeader = Format(Now, "MMM")
    End With
End Sub

Right click the Excel icon to the left of File on the menu and choose View Code. Paste in the above.
 

eliW

Well-known Member
Joined
Mar 2, 2002
Messages
1,931
On 2002-10-02 08:09, Andrew Poulsom wrote:
I don't know a way to do it without VBA.

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    With ActiveSheet.PageSetup
        .LeftHeader = Format(Now, "MMM")
    End With
End Sub

Right click the Excel icon to the left of File on the menu and choose View Code. Paste in the above.

Thanks a lot Andrew, It works fine.
Just one more question: I'll use this code to put a whole sentence like:
LeftHeader = "Report for " & Format(Now, "MMM,YYYY")

How can I put an underline for this header?

Eli
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Like this:

.LeftHeader = "&UReport for " & Format(Now, "MMM,YYYY")

Look up the LeftHeader property in VBA Help and click "format codes" for more options.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,307
Messages
5,600,869
Members
414,411
Latest member
Snowmanaus

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
Top