Saving of Date and Time in a Cell

JamesMitel

New Member
Joined
Apr 29, 2015
Messages
2
Hello,

I have created a database in excel with multiple sheets with various functions and stored on OneDrive which allows others to see it.

What I require is for it to show the Time and Date it was last saved in a particular cell in a worksheet.

I have done various searchers across the net and tried multiple things using VB (Visual Basic) but have had no luck. A quick search on this forum showed me how to do the last time saved, but not both Time AND Date.

Another thing, will this macro continue to function if hosted on onedrive - I usually click 'open with Excel application' - but need others to see the date.


Help on this matter is greatly appreciated - I've been scratching my head for the past few days now!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hey James,

Paste below code in vb sheet called "ThisWorkbook".

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("tracker").Range("B2") = Format(Now, "dd/mm/yy hh:mm:ss")
End Sub
Private Sub Workbook_Open()
Sheets("tracker").Range("B3") = Format(Now, "dd/mm/yy hh:mm:ss")
End Sub

Kindly note that you should change the name and range either in your workbook or in above coding to run it perfectly.
 
Upvote 0
Hey James,

Paste below code in vb sheet called "ThisWorkbook".

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("tracker").Range("B2") = Format(Now, "dd/mm/yy hh:mm:ss")
End Sub
Private Sub Workbook_Open()
Sheets("tracker").Range("B3") = Format(Now, "dd/mm/yy hh:mm:ss")
End Sub

Kindly note that you should change the name and range either in your workbook or in above coding to run it perfectly.

Thanks for that! -Which 'name' is it that I need to change? - Would that be the name I have called that particular sheet and where in the code above do I make the change?

Range I'm guessing is the cell it will go on - so B3 being the cell location according to the code?
 
Upvote 0
Hey James,

Name change here is indicating sheet name change. Like if you have sheet name is Sheet1, then change the code accordingly.
e.g.Sheets("Sheet1").Range("B2") = Format(Now, "dd/mm/yy hh:mm:ss")

Range change means, yes you are right. B2 and B3 would be the cell in which it will show the last time of file opening and closing. In B2, it will show you the file open time and in B3 it will show the file closing time.
 
Upvote 0

Forum statistics

Threads
1,216,577
Messages
6,131,511
Members
449,653
Latest member
andz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top