Suppose you have a folder directly below the drive as shown below.
I would like to aggregate the number of files and the last update date and time on EXCEL for folders A, B, and C just below these drives.
(Not applicable to subfolders in A, B, and C)
Is it possible to do the above?
vba excel batch-file
By the way, Excel has a feature called Power Query.This is a proprietary language that retrieves and outputs a variety of data in the form of a table on Excel, so you can achieve the table you want.
Run Data > Retrieve Data > Launch Power Query Editor and
Select Home - New Source - Other Sources - Empty Query and click
Enter the following code in Home > Advanced Editor and
Run Home > Close and Load.
let
Source = Folder.Contents("C:\"),
Narrowing = Table.SelectRows (source, each List.Contains({"A", "B", "C"}, [Name]),
Add File Count = Table.AddColumn (narrowed, "Files Count", each List.Count (List.Select ([Content][Attributes], each [Kind]<"Folder")),
Column order = Table.SelectColumns (add file count, {"Name", "file count", "Date modified"},
Column name change = Table.RenameColumns (column order, {{"Name", "Folder Name", {"Date modified", "Last Updated"}}})
in
column renaming
You should now enter a table similar to the following:
Data - Update All updates the contents of the table, which rewrites the filename and the date and time of the last update.
Unlike VBA, it doesn't require supporting information such as which cells, what data, and so on, and it's easy to use because it's purely data-processing.
vba
can be accomplished by using the FileSystemObject.GetFolder
method as follows:
Last update date and time is DateLastModified
property of
© 2024 OneMinuteCode. All rights reserved.