PDA

View Full Version : Time Stamp VBA - Need help please!



kirkas
08-06-2008, 11:55 AM
I was fortunate enough to run across the following code from this site..


Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("A7").Value = "vbGeneralDate"
Range("B7").Value = FormatDateTime(Now, vbGeneralDate)
Columns("A:B").EntireColumn.AutoFit
Range("A1").Select
End Sub

I need help with the following

I have 4 worksheets and each one of them has a different number of
rows.

I want the date and time stamp to appear at a certain position for
each of the sheets. For example one is A8 B8 on another sheet it is A 107 B 107
I need to find a way to have the date stamp appear in different places on different worksheets. Or, Ideally, Have the date stamp appear in the footer. For this project it is very important that I know when the last hard save was done

Any thoughts/ideas/help on the matter would be greatly appreciated. Glad I found this forum!

-K

Bob Phillips
08-06-2008, 12:49 PM
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets

Select Case ws.Name

Case "ABC"
ws.Range("A8").Value = "vbGeneralDate"
wb.Range("B8").Value = FormatDateTime(Now, vbGeneralDate)
wb.Columns("A:B").EntireColumn.AutoFit

Case "XYZ"
ws.Range("A107").Value = "vbGeneralDate"
wb.Range("B107").Value = FormatDateTime(Now, vbGeneralDate)
wb.Columns("A:B").EntireColumn.AutoFit

'etc
End Select
Next ws

ThisWorkbook.Save

End Sub