#1   Report Post  
Posted to microsoft.public.excel.misc
tfred
 
Posts: n/a
Default macro

How can I set an excel spreadsheet to automatically insert a current date and
save that date when the workbook is closed. The next time the workbook is
open on a different day it inserts the current date two rows from the last
row that contains data. For example:

Date: 05/09/06 €“ Automatic insert current date when Workbook is open
Tom Hanks 8hr $12.00 Hr.
Paul Thomas 10hr $11.00 Hr.

Close workbook€¦.date is saved automatically
Next day€¦.open workbook and Excel automatically inserts the current date two
rolls down from last data entered. For example:

Date: 05/09/06
Tom Hanks 8hr $12.00 Hr.
Paul Thomas 10hr $11.00 Hr.


Date: 05/10/06
Tom Hanks 7hr $12.00 Hr.
Paul Thomas 8hr $11.00 Hr.
Sue Smith 8hr $12.00 Hr.

  #2   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default macro


Sounds like you want a couple of macros linked to the
Workbook_BeforeClose and Workbook_Open.

The line would be something like...

Cells(65536,1).end(xlup).offset(0,2) = Now()


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=540341

  #3   Report Post  
Posted to microsoft.public.excel.misc
tfred
 
Posts: n/a
Default macro

mrice,
Thank you for your help. I have two questions.....Isnt there a way to have
the workbook run a macro automatically when you open the workbook? (that way
it would eliminate manually running a macro) If so, cant I just have the
date coded in the macro like the short cut ctrl + : That way I could just
save without running a close macro.

Sounds like you want a couple of macros linked to the
Workbook_BeforeClose and Workbook_Open.

The line would be something like...

Cells(65536,1).end(xlup).offset(0,2) = Now()


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=540341


  #4   Report Post  
Posted to microsoft.public.excel.misc
Abode
 
Posts: n/a
Default macro

This should work. If you don't know where to put it, press F11 with Excel
active. Then in the Visual Basic Editor click on the workbook you wish to
add this macro into and click on the "ThisWorkbook" file. Then just cut and
paste this into it. Unfortunately it doesn't acount for if the workbook is
opened multiple times in one day. Someone else may provide some refining to
the code to make it look a lot better (Im new to VB). If you want it to only
add a new entry on a new day let me know and I'll see if I can write it up
quickly.

Be sure to adjust "Sheet4" to your worksheet name and have the quotes in
there. Same thing with "A" if you wish for the macro to search for the last
row and write on a different column.

Sub Workbook_Open()
Dim i As Integer

i = 1
Do While (Worksheets("Sheet4").Range("A" & i).Value < "") Or
(Worksheets("Sheet4").Range("A" & i + 1).Value < "")
i = i + 1
Loop
i = i + 1

Worksheets("Sheet4").Range("A" & i).Value = "Date: " & Date

End Sub

"tfred" wrote:

mrice,
Thank you for your help. I have two questions.....Isnt there a way to have
the workbook run a macro automatically when you open the workbook? (that way
it would eliminate manually running a macro) If so, cant I just have the
date coded in the macro like the short cut ctrl + : That way I could just
save without running a close macro.

Sounds like you want a couple of macros linked to the
Workbook_BeforeClose and Workbook_Open.

The line would be something like...

Cells(65536,1).end(xlup).offset(0,2) = Now()


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=540341


  #5   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default macro


You could also use a macro titled

AUTO_OPEN

to acheive the same thing.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=540341

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
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 05:52 PM.

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"