Excel formula to report date modified

I have an Excel file (Daily Asset Allocation Report.xlsx) and I would like an Excel formula or script which reports (in cell D23, "Start Here" worksheet) the date and time that another Excel file was last modified.  

The filename/path of the file that I want to have Excel report the modified date for is always I:\Interfund Transfers\Interfund Transfer.xlsx.  

Thank you.
Kevin BucklandInvestment OfficerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
here you go:

Worksheets("Start Here").Range("D23") = FileDateTime("I:\Interfund Transfers\Interfund Transfer.xlsx")

:)
0
Kevin BucklandInvestment OfficerAuthor Commented:
Sorry I know just enough to be dangerous... Can you tell me how and where to put this code?

Thank you
0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
LOL... of course!  Do you know how to record a macro?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Kevin BucklandInvestment OfficerAuthor Commented:
Yes, I can record a macro.
0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
1. Open the workbook in which you want the date check  to run.  The "Record Macro" window will open.
2.  Start recording a macro;  name it "CheckInterfundTransfer.xlsxDate"  (or something;  you just need to be able to recognize it).
3.  Give it a shortcut key.
4.  Confirm the macro will be stored in "This Workbook"
5.  Click OK.

type a couple of letters, then stop recording.

6.  Press Alt-F11. The Microsoft Visual Basic for Applications window will open.  Find the macro you just recorded.
7.  There will be a line that looks something like this
                     ActiveCell.FormulaR1C1 = "abc"   (or whatever letters you typed)
delete that line, and paste
                     Worksheets("Start Here").Range("D23") = FileDateTime("I:\Interfund Transfers\Interfund Transfer.xlsx")

8.  Close the Microsoft Visual Basic for Applications window, and return to your workbook.
9.  Press the shortcut keys;  Start Here.D23 should be populated with the date and time of the last update.

Let me know if you get stuck.  :)
0
Kevin BucklandInvestment OfficerAuthor Commented:
OK, I'm getting a compile error: Invalid Outside Procedure.  It highlighted "I:\Interfund Transfers\Interfund Transfer.xlsx"
0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
when you look at the VBA window, the macro should look like this:

Sub CheckInterfundTransferDate()
'
' MacrCheckInterfundTransferDateo2 Macro
'
' Keyboard Shortcut: Ctrl+Shift+C
Worksheets("Start Here").Range("D23") = FileDateTime("I:\Interfund Transfers\Interfund Transfer.xlsx")

End Sub

Open in new window


If that's not the way it looks, and you can't get it to work, copy and paste the macro you created.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShumsDistinguished Expert - 2017Commented:
I got something which will show you on Msg but I am still trying to get into Workbook Log:
Sub GetDate()

    Dim oFS As Object
    Dim strFilename As String

    'Put your filename here
    strFilename = "I:\Interfund Transfers\Interfund Transfer.xlsx"


    'This creates an instance of the MS Scripting Runtime FileSystemObject class
    Set oFS = CreateObject("Scripting.FileSystemObject")

    MsgBox strFilename & " was created on " & oFS.GetFile(strFilename).DateCreated & " was last modified on " & oFS.GetFile(strFilename).Datelastmodified



    Set oFS = Nothing

End Sub

Open in new window

0
ShumsDistinguished Expert - 2017Commented:
This is another approach to get on D23, but it can't get log of modification:
Sub GetDate()

    Dim oFS As Object
    Dim strFilename As String

    'Put your filename here
    strFilename = "I:\Interfund Transfers\Interfund Transfer.xlsx"


    'This creates an instance of the MS Scripting Runtime FileSystemObject class
    Set oFS = CreateObject("Scripting.FileSystemObject")

    Cells(23, 4) = strFilename & " was created on " & oFS.GetFile(strFilename).DateCreated & " was last modified on " & oFS.GetFile(strFilename).Datelastmodified



    Set oFS = Nothing

End Sub

Open in new window

0
ShumsDistinguished Expert - 2017Commented:
Check this with only Date & Time of Last Modification on D23:
Sub GetDate()

    Dim oFS As Object
    Dim strFilename As String

    'Put your filename here
    strFilename = "I:\Interfund Transfers\Interfund Transfer.xlsx"


    'This creates an instance of the MS Scripting Runtime FileSystemObject class
    Set oFS = CreateObject("Scripting.FileSystemObject")

    Cells(23, 4) = oFS.GetFile(strFilename).Datelastmodified

    Set oFS = Nothing

End Sub

Open in new window

0
ShumsDistinguished Expert - 2017Commented:
Here you go...
Click on Update Result. You will get first date and time of your file. Open your source file / save / close, then click update result again, your second date and time will be update on top of the row. This way you can keep the log of your file, since last updated.
Sub GetDate()
Dim FSO As Object
Dim SourceFolder As String
Dim FileName As String
Dim Ws As Worksheet
Dim LR As Long
Set Ws = Worksheets("Sheet1")
LR = Ws.Range("B" & Rows.Count).End(xlUp).Row

SourceFolder = Ws.Range("B4").Value
Set FSO = CreateObject("Scripting.FileSystemObject")
FileName = SourceFolder & Ws.Range("B6").Value

Ws.Cells(8, 2) = FSO.GetFile(FileName).Datelastmodified

Set FSO = Nothing

If Ws.Cells(8, 2).Value = Ws.Cells(12, 2).Value Then
    Ws.Cells(12, 2).Value = Ws.Cells(8, 2).Value
    Ws.Range("A12:A" & LR).FormulaR1C1 = "=MAX(R11C1:R[-1]C)+1"
    Ws.Range("A12:A" & LR).Value = Ws.Range("A12:A" & LR).Value
Else
    Ws.Cells(12, 2).EntireRow.Insert Shift:=xlDown
    Ws.Cells(12, 2).Value = Ws.Cells(8, 2).Value
    Ws.Range("A12:A" & LR + 1).FormulaR1C1 = "=MAX(R11C1:R[-1]C)+1"
    Ws.Range("A12:A" & LR + 1).Value = Ws.Range("A12:A" & LR + 1).Value
End If
Ws.Range("A10").Select
End Sub

Open in new window

Please find attached for your reference.
Daily-Asset-Allocation-Report.xlsm
0
ShumsDistinguished Expert - 2017Commented:
If you want to change the path - change in B4, and if you want to change the file name change the full filename with extension in B6. You can Keep log of any file by saving above workbook with another log book name.
0
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
Kevin, I'm reposting this in case you didn't see it earlier.  :)  
P

When you look at the VBA window, the macro should look like this:
Sub CheckInterfundTransferDate()
'
' MacrCheckInterfundTransferDateo2 Macro
'
' Keyboard Shortcut: Ctrl+Shift+C
Worksheets("Start Here").Range("D23") = FileDateTime("I:\Interfund Transfers\Interfund Transfer.xlsx")
End Sub

Open in new window

If that's not the way it looks, and you can't get it to work, copy and paste the macro you created.
0
Kevin BucklandInvestment OfficerAuthor Commented:
Thanks much, works like a charm!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.