I need to have a cell in an Excel worksheet display the full path of the file and the date the file was created or maybe modified. I've worked with VBA in Access, but never in Excel.
You can add this code to the sheet's object. This is for the complete path and filename. I am not sure how to get the date the file was originally created.
Code:
Private Sub Worksheet_Activate()
Range("A1").FormulaR1C1 = ThisWorkbook.FullName
End Sub
Thanks, but why does it display the old location after I move it then open it again? If I go to other worksheets then back to the Sheet1 the location refreshes. When does this Worksheet Activate event fire if not on the opening of the Workbook?
That subroutine runs when the worksheet is activated (upon switching sheets). If you want this to update only once, when the workbook is opened, add this code to a module (not the sheet object).
Code:
Sub Auto_Open()
Range("A1").FormulaR1C1 = ThisWorkbook.FullName
End Sub
I am sure that there is a way to get the file creation date, but I am not sure exactly how. I will poke around, but in the meantime, I am sure that one of the other experts in this forum can help.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.