I have an Excel Spreadsheet that I would like the date it is first opened to be inserted into a cell. I do not want the date to be updated if the file is subsequently opened and/or saved.
Is there a way I can do this?
Regards,
Barrie Bowdler
I'm a bit confused by this. If you have this spreadsheet already, then it has already been opened. So any subsequent opening will never be recorded per your requirements.
Are you talking about opening a blank, new spreadsheet?
Recommend using an "Autpen" macro to check and see if the target cell is blank, and if so, place the current date there. Once the date occupies the cell, it will not be changed again.
Adding to what's already been said is this any use?
Code:
Private Sub Workbook_Open()
If [a1].Value <> "" Then Exit Sub
[a1].Value = Format(Now, "dd/mm/yy hh:mm:ss")
End Sub
To use the code whilst in xl hit Alt+F11. On the left hand side you should see the project explorer window (if not hit Ctrl+R). You should see your workbook listed as VBAProject (yourworkbook name) - double click on the ThisWorkbook module. Paste the code into this.
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.