How do I extract the last update date from a different excel file?

D

Dennis

I need to place the last update date of a data file that I use to extract
data to a different file. I need the formula to place this date in a cell at
the top of my working file. Thanks
 
G

Gary''s Student

Here is the general idea:

Sub NeedADate()
Dim FSO As Scripting.FileSystemObject
Dim FileItem As Scripting.File
Set FSO = New Scripting.FileSystemObject
filespec = "C:\test\tulip.jpg"
Set FileItem = FSO.GetFile(filespec)
MsgBox (FileItem.DateLastModified)
End Sub

You must include a reference to Microsoft Scripting Runtime

You would use your real data file in place of the .jpg
and
to store the date, something like:

Range("A1").Value=FileItem.DateLastModified
 
R

Rick Rothstein

You can use VB's FileTimeDate function to do that directly (without needing
any additional references)...

MsgBox FileDateTime("C:\test\tulip.jpg")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top