Date each active tab upon save

K

Ken King

I would like to write a macro that would write the date & time to a cell in
the active worksheet tab, the same location for each tab, upon saving the
workbook. Could someone help me with this macro?

Thanks,
Ken
 
G

Gary''s Student

Sub demo()
Dim w As Worksheet
For Each w In Worksheets
w.Activate
Range("A1") = Now()
Next
End Sub
 
J

John Collins

Gary''s Student said:
Sub demo()
Dim w As Worksheet
For Each w In Worksheets
w.Activate
Range("A1") = Now()
Next
End Sub

I think the writer asks for a way to mark only the active sheet each
time a book is saved. If you put it into auto close, then it could run
when the book is closed.

Sub auto_close()
Activesheet.Range("A1").Value = Now()
End Sub

I don't know how to modify ActiveWorkbook.Save so that it includes the
desired code. As an alternative, instead of using the File:Save menu or
the Save button, you could create your own menu item or toolbar button
called MarkandSave that had the following code.

Sub MarkandSave
Activesheet.Range("A1").Value = Now()
Activeworkbook.Save
End Sub

John
 
K

Ken King

John Collins said:
I think the writer asks for a way to mark only the active sheet each
time a book is saved. If you put it into auto close, then it could run
when the book is closed.

Sub auto_close()
Activesheet.Range("A1").Value = Now()
End Sub

I don't know how to modify ActiveWorkbook.Save so that it includes the
desired code. As an alternative, instead of using the File:Save menu or
the Save button, you could create your own menu item or toolbar button
called MarkandSave that had the following code.

Sub MarkandSave
Activesheet.Range("A1").Value = Now()
Activeworkbook.Save
End Sub

John

John,

This is exactly what I want, but I forgot to include adding the username
(person who is modifying tab) to a cell below.

Thanks,
Ken
 
Top