Full Version: dating a worksheet
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
SDiego
I have created a workbook with 2 sheets. But I want to name the worksheets and I also want each worksheet to have today's date. What kind of code would I use to name and date my to worksheets?
argeedblu
Welcome to Utter Access.

In one cell use the function =Today() and format it as date. If you want the date to update everytime the worksheet is recalculated, use =Now() instead.

You can also put the current date and time in the header/footer under page setup.

Glenn
NateO
Hello, just note, date functions in Excel are volatile, making them both expensive to a workbook's recalculation and a moving target. Here's a block of code that you're looking for:

Sub NmeNDate()
Sheets(1).Name = Format(Date, "mm-dd-yyyy")
Sheets(1).[a1] = Format(Date, "mm-dd-yyyy")
[color="#00007F"]End [color="#00007F"]Sub

You can't use "/" in worksheet names, so you must be the bigger person and compromise here.

Bon chance.
argeedblu
Good point, Nate. I was sure that I had recalled from somewhere that one of the two function wasn't volatile but realize now that I must be thinking of one of the other spreadsheet products. From time to time I'm called upon to teach Quattro Pro, and Lotus 123. And I had completely missed the second part of the original poster's question. Thanks for setting me on the right path

Glenn
NateO
Hello Glenn, not sure about Quattro or Lotus, but In Excel they're both volatile.

You are welcome.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.