I need to summarize Last Saved or Modified dates from multiple workbooks

mikeTRON

New Member
Joined
Sep 27, 2012
Messages
42
So I am new to VBA but I am decent with excel. Basically I have a macro that opens and copy->pastes data from 24 files into one Summary file. It works correctly, although I'm sure it is ugly :). So in Column B I have the workbook names and in Column C I have a flag (Yes or No) to update the data from that workbook. Now what I am wanting to do is somehow capture the date modified of each of the files so I know if it is the most current data.

I cant think of a way for an excel formula to do the trick but I have found the following:

Place this code in the workbook code page:
Code:
Code:
Option Explicit

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    ThisWorkbook.Sheets(1).Range("A1") = ReturnWhenModifiedDate
End Sub

Code:
Code:
Option Explicit

Function ReturnWhenModifiedDate() As Date
    'Called by Workbook Before_Save event
    
    Dim fso As Object, f As Object
    
    If thisworkbook.Path = vbNullString Then
        'File has never been saved
        ReturnWhenModifiedDate = Now() 'Return current date/time
    Else
        'File saved previously return that time
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set f = fso.GetFile(thisworkbook.Path & "\" & thisworkbook.Name)
        ReturnWhenModifiedDate = f.DateLastModified
        Set f = Nothing
        Set fso = Nothing
    End If

End Function

Found here: http://www.mrexcel.com/forum/excel-...g-last-modified-date-cell-a1.html#post3228961

I also found:

Code:
?excel.Application.ThisWorkbook.BuiltinDocumentProperties.count
 30 
?excel.Application.ThisWorkbook.BuiltinDocumentProperties("Last Author")
Sutter Connect
?excel.Application.ThisWorkbook.BuiltinDocumentProperties("Creation Date")
10/14/1996 4:33:28 PM 
?excel.Application.ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
11/29/2005 1:10:27 PM



Can someone help me encorporate this or any system into my macro?

Thanks!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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