actual month

S

sheva

I would like to make an excel sheet and i need a cell that shows only the
actual year and month.
This cell should be in the header of this document.

How can I do it?
Please help me! Thank you!
 
B

Bernard Liengme

In a cell (A1 for example) enter =TODAY()
Use Tools|Macro|VBA Editor
In the Project window (left panel) locate your workbook, click on This
Workbook
Paste this subroutine

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim dte As Date
dte = Date
With ActiveSheet.PageSetup
.LeftHeader = Format(dte, "mmmm yyyy")
End With
End Sub

When you print, the month and year will be in left header; you can easily
make it Center or Right

The format is flexible; use mmm (3 m's) to get abbreviation
Use m/yy to get, for example 4/06

best wishes
 
J

JE McGimpsey

If you want it in a cell:

=TODAY()

Format with Format/Cells/Number/Custom "YYYY MMMM"

(or whatever format you want).

If you actually want it in the header. Put this in the ThisWorkbook code
module...

Private Sub Workbook_Open()
Sheets(1).PageSetup.LeftHeader = Format(Date, "YYYY MMMM")
End Sub

If you're not familiar with macros see

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top