Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automatically enter today's date as a static entry

I have a need to automatically save the current date to a cell in an excel spreadsheet every time the sheet is saved.

Today() always returns the current date, so once I open the sheet on a new day I can no longer see the date the information was last updated, i.e. saved.

Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Automatically enter today's date as a static entry

David,
Are you familiar with Visual Basic? If so, try this code in ThisWorkbook
section.

Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").Select
Range("A1").Select
ActiveCell.Value = Now
End Sub

Actually, this returns an entire Date/Time stamp. If you wanted just the
date you could use DateSerial(Year(Now),Month(Now),Day(Now)) where "Now" is
above.

Dave


"David" wrote:

I have a need to automatically save the current date to a cell in an excel spreadsheet every time the sheet is saved.

Today() always returns the current date, so once I open the sheet on a new day I can no longer see the date the information was last updated, i.e. saved.

Any help would be appreciated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Automatically enter today's date as a static entry

Hi David,

in the ThisWorkbook module -

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

'if don't want date if no changes since last save
If ThisWorkbook.Saved = True Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
Worksheets("Sheet1").Range("A1") = Now
Worksheets("Sheet1").Range("A2") = Date
Application.EnableEvents = True

End Sub

Handy keyboard short cuts
Ctrl ;
semicolon - date
with shift or colon - time

Regards,
Peter T

PS FYI, my newsreader removed an attachment from your post it decided was
unsafe.

"David" wrote in message
...
I have a need to automatically save the current date to a cell in an excel
spreadsheet every time the sheet is saved.

Today() always returns the current date, so once I open the sheet on a new
day I can no longer see the date the information was last updated, i.e.
saved.

Any help would be appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically enter today's date as a static entry


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel A
Boolean)

ThisWorkbook.Sheets("Sheet1").Range("A1").Value = Now

End Sub


1. Replace "Sheet1" with the name of the sheet where you want to inser
the date.

2. Replace "A1" with the address of the cell where you want to ente
the date.

The Workbook_beforeSave event is an event of "Thisworkbook" object.

Juan Carlo

--
cscor
-----------------------------------------------------------------------
cscorp's Profile: http://www.excelforum.com/member.php...fo&userid=2401
View this thread: http://www.excelforum.com/showthread.php?threadid=37655

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Automatically enter today's date as a static entry

Thanks Peter, yours seems to have worked best of all the solutions I
received. The others may have worked just as well if I knew more about VB.

Can I take care of formatting so it ends up as March 12, 2005 in your code
vs. in the spreadsheet?

Thanks again for your help.

"Peter T" <peter_t@discussions wrote in message
...
Hi David,

in the ThisWorkbook module -

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

'if don't want date if no changes since last save
If ThisWorkbook.Saved = True Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
Worksheets("Sheet1").Range("A1") = Now
Worksheets("Sheet1").Range("A2") = Date
Application.EnableEvents = True

End Sub

Handy keyboard short cuts
Ctrl ;
semicolon - date
with shift or colon - time

Regards,
Peter T

PS FYI, my newsreader removed an attachment from your post it decided was
unsafe.

"David" wrote in message
...
I have a need to automatically save the current date to a cell in an excel
spreadsheet every time the sheet is saved.

Today() always returns the current date, so once I open the sheet on a new
day I can no longer see the date the information was last updated, i.e.
saved.

Any help would be appreciated.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Automatically enter today's date as a static entry

Use this then

Worksheets("Sheet1").Range("A1").Value = Format(Date, "mmm dd yyyy")


--
Regards Ron de Bruin
http://www.rondebruin.nl



"David" wrote in message ...
Thanks Peter, yours seems to have worked best of all the solutions I received. The others may have worked just as well if I knew
more about VB.

Can I take care of formatting so it ends up as March 12, 2005 in your code vs. in the spreadsheet?

Thanks again for your help.

"Peter T" <peter_t@discussions wrote in message ...
Hi David,

in the ThisWorkbook module -

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

'if don't want date if no changes since last save
If ThisWorkbook.Saved = True Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
Worksheets("Sheet1").Range("A1") = Now
Worksheets("Sheet1").Range("A2") = Date
Application.EnableEvents = True

End Sub

Handy keyboard short cuts
Ctrl ;
semicolon - date
with shift or colon - time

Regards,
Peter T

PS FYI, my newsreader removed an attachment from your post it decided was
unsafe.

"David" wrote in message
...
I have a need to automatically save the current date to a cell in an excel
spreadsheet every time the sheet is saved.

Today() always returns the current date, so once I open the sheet on a new
day I can no longer see the date the information was last updated, i.e.
saved.

Any help would be appreciated.






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Automatically enter today's date as a static entry

Can I take care of formatting so it ends up as March 12, 2005 in your code
vs. in the spreadsheet?


Assuming the address of the cell you saving the date to is hardcoded,
manually format the cell to display the date as required, no need to do it
each time in the Save event (providing user hasn't changed it).

Or if needs, with code

myCell.NumberFormat = "mmmm dd, yyyy"

Regards,
Peter T


"David" wrote in message
...
Thanks Peter, yours seems to have worked best of all the solutions I
received. The others may have worked just as well if I knew more about

VB.

Can I take care of formatting so it ends up as March 12, 2005 in your code
vs. in the spreadsheet?

Thanks again for your help.

"Peter T" <peter_t@discussions wrote in message
...
Hi David,

in the ThisWorkbook module -

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

'if don't want date if no changes since last save
If ThisWorkbook.Saved = True Then Exit Sub

On Error Resume Next
Application.EnableEvents = False
Worksheets("Sheet1").Range("A1") = Now
Worksheets("Sheet1").Range("A2") = Date
Application.EnableEvents = True

End Sub

Handy keyboard short cuts
Ctrl ;
semicolon - date
with shift or colon - time

Regards,
Peter T

PS FYI, my newsreader removed an attachment from your post it decided

was
unsafe.

"David" wrote in message
...
I have a need to automatically save the current date to a cell in an

excel
spreadsheet every time the sheet is saved.

Today() always returns the current date, so once I open the sheet on a

new
day I can no longer see the date the information was last updated, i.e.
saved.

Any help would be appreciated.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If cell is blank automatically enter today's date in the same cell LCTECH001 Excel Discussion (Misc queries) 22 April 5th 23 02:50 PM
automatically enter today's date as a static entry in Excel TJ Excel Discussion (Misc queries) 3 July 25th 08 04:44 AM
in excel how do enter today's date on a laptop bency New Users to Excel 3 August 30th 05 01:37 AM
Automatically enter today's date as a static entry David Links and Linking in Excel 2 June 6th 05 12:08 AM
Automatically enter today's date as a static entry David Excel Worksheet Functions 1 June 4th 05 04:54 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"