ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Date Button in Header (Excel 2000) (https://www.excelbanter.com/excel-discussion-misc-queries/1717-date-button-header-excel-2000-a.html)

Jim

Date Button in Header (Excel 2000)
 
Is there a way to change the format of the date button in the header? I get
12/11/04 and would like December 11, 2004.

Thanks,
Jim

Dave Peterson

I bet you're writing about File|page setup|Header/footer tab and clicking that
date button to insert the current date (you get this: &[Date] in the header
section.

If yes, you could type anything you want (a static date, though). Or you could
use a macro that sets the header whenever you print/print preview.

I recorded a macro when I changed the header. I got this code (after deleting
lots of stuff I didn't care about):

With ActiveSheet.PageSetup
.RightHeader = "&D"
End With

I could change it to:

With ActiveSheet.PageSetup
.RightHeader = format(date,"mmmm dd, yyyy")
End With

But if you live with what I did, you may lose stuff that you want.

So record your macro and modify it according to what you really want (along with
the date stuff).

But now you have to put that code in a special spot.

Inside the VBE (where that recorded macro is)
hit ctrl-r (to see the project explorer)
find your project and expand it using the +'s in front of each object. (Just
like Windows explorer and folders.)

When you see ThisWorkbook, double click on it and paste your code there.

But you'll have to modify it slightly. I used this:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Me.Worksheets("sheet1")
.RightHeader = Format(Date, "mmmm dd, yyyy")
End With
End Sub

I only want the right header of worksheets Sheet1 to get that head--and I don't
want anything else to change.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



Jim wrote:

Is there a way to change the format of the date button in the header? I get
12/11/04 and would like December 11, 2004.

Thanks,
Jim


--

Dave Peterson


All times are GMT +1. The time now is 04:37 AM.

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