Excel VBA Macro: List Time Last Saved (For All Files In Folder)
Excel VBA Macro: List Time Last Saved (For All Files In Folder). In this video, we go over how to automatically list the file names and last saved times for all files in a user selected folder. We also have the macro show the file location, and create a message for the user if there are no files in the selected folder.
Code (YouTube doesn't allow brackets; so LT and GT are used for less than and greater than, respectively):
Sub list_last_save_times()
Dim myPath As String
Dim myFile As String
Dim FldrPicker As FileDialog
Dim sh As Worksheet
Dim i As Integer
Application.ScreenUpdating = False
Set sh = ThisWorkbook.Sheets("Last Save Times")
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Please Select Folder"
.AllowMultiSelect = False
.ButtonName = "Confirm!!!"
If .Show = -1 Then
myPath = .SelectedItems(1) & "\"
Else
End
End If
End With
sh.Activate
sh.Cells.ClearContents
Cells(1, 1) = "File Name(s)"
Cells(1, 2) = "Last Time Saved"
Cells(1, 4) = "Location:"
Cells(1, 5) = myPath
myFile = Dir(myPath)
i = 1
Do While myFile LTGT ""
sh.Cells(i + 1, 1) = myFile
Workbooks.Open Filename:=myPath & myFile
With sh.Cells(i + 1, 2)
.Value = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
.NumberFormat = "mm-dd-yyyy h:mm AM/PM"
End With
ActiveWorkbook.Close savechanges:=False
myFile = Dir
i = i + 1
Loop
sh.Range("A:B").Columns.AutoFit
If i = 1 Then
MsgBox "There are no items in this folder"
End If
Application.ScreenUpdating = True
End Sub
#ExcelVBA #ExcelMacro
Видео Excel VBA Macro: List Time Last Saved (For All Files In Folder) канала greggowaffles
Code (YouTube doesn't allow brackets; so LT and GT are used for less than and greater than, respectively):
Sub list_last_save_times()
Dim myPath As String
Dim myFile As String
Dim FldrPicker As FileDialog
Dim sh As Worksheet
Dim i As Integer
Application.ScreenUpdating = False
Set sh = ThisWorkbook.Sheets("Last Save Times")
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Please Select Folder"
.AllowMultiSelect = False
.ButtonName = "Confirm!!!"
If .Show = -1 Then
myPath = .SelectedItems(1) & "\"
Else
End
End If
End With
sh.Activate
sh.Cells.ClearContents
Cells(1, 1) = "File Name(s)"
Cells(1, 2) = "Last Time Saved"
Cells(1, 4) = "Location:"
Cells(1, 5) = myPath
myFile = Dir(myPath)
i = 1
Do While myFile LTGT ""
sh.Cells(i + 1, 1) = myFile
Workbooks.Open Filename:=myPath & myFile
With sh.Cells(i + 1, 2)
.Value = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
.NumberFormat = "mm-dd-yyyy h:mm AM/PM"
End With
ActiveWorkbook.Close savechanges:=False
myFile = Dir
i = i + 1
Loop
sh.Range("A:B").Columns.AutoFit
If i = 1 Then
MsgBox "There are no items in this folder"
End If
Application.ScreenUpdating = True
End Sub
#ExcelVBA #ExcelMacro
Видео Excel VBA Macro: List Time Last Saved (For All Files In Folder) канала greggowaffles
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Excel VBA Macro: Open Newest Files (from Multiple Folders) and Save Them in Another FolderComment Out Blocks of Code 🤓 #excelmacro #excelvba #msexcelExcel VBA Macro: Delete All Sheets that Contain a Certain Text (String) ValueExcel VBA Macro: Resize Range (Table) Pasted As Image In Email BodyExcel VBA Macro: Count and List the Number of (Conditonally Formatted) Cells at the End of Each RowExcel VBA Macro: Save File As Previous Work/Business Day (Excluding Holidays)Excel VBA Macro: Send Email with Hyperlink (that has Spaces in the File Name)Excel VBA Macro: Right Align Image in Email Body (and Resize)Excel VBA Macro: Delete Rows If Any Cell in Those Rows (Across All Columns) Contains a Certain ValueExcel VBA Macro: Autofilter And Copy/Paste To Multiple Sheets (Dynamic Range)Excel VBA Macro: Resize Large Table Ranges After Pasting (As Image) In Email BodyExcel VBA Macro: Export Selected Range as Image (Save Range as Picture)Excel VBA Macro: Send Email with Attachments from a List (Dynamic Range)Excel VBA Macro: Remove Special Characters (in List of Strings) & Post New Strings Next to Old OnesExcel VBA Macro: Capitalize First Letter of Every Word in a (Static/Dynamic) Range of StringsExcel VBA Macro: Find Sheet in Another (User Selected) Workbook and Copy Data OverExcel VBA Macro: Create Word Document & Add Table (Static Range)Excel VBA Macro: List All Sheet/Tab Names (From Another User Selected Workbook)Excel VBA Macro: Add New Sheets To Beginning Or End of Workbook (With Names)Excel VBA Macro: Save Selected Range as PDF (and Center on Page)