Hi Taurean,
Did you get any response / answer to this yet?
Lisa Green ( Group Moderator )
-----Original Message-----
From: Taurean KV taureankv@gmail.com [ExcelVBA] <ExcelVBA@yahoogroups.com>
To: ExcelVBA <ExcelVBA@yahoogroups.com>
Sent: Sat, Jul 15, 2017 8:13 pm
Subject: [ExcelVBA] File Finder
Hi, Need your advise and help on this.
I'm using couple of codes including the one below. This code helps in extracting files that were updated beyond a date.
I need your assistance in applying a small change that will only extract files if a folder/subfoIder/and further down was updated beyond a date. It is only when the macro will get in that folder and extract those files.
Currently, if folder A has a subfolder B and within B there is subfoIder C. If a excel file was updated in subfolder C then folder C will also show the same last modified date, while the folder A and B will not. By doing this the macro will only enter that folder which shows last modified date or in case if the user defined date is any day prior to the aforesaid modified date.
My hunch is that at present the macro is going through each folder and scanning through each file hence taking a lot of time..
Thanks in advance for help here.
Sub Start()
Dim FiIeSystem As ObjectDim HostFolder As String
HostFolder = "\\c: drive"
Set FileSystem= CreateObject ("Scripting.FileSystemObject")
DoFolder FileSystem.GetFoIder(HostFolder)
End Sub
Sub DoFolder(Folder)
Dim SubFoIder
For Each SubFoIder In Folder.SubFolders DoFolder SubFoIderNext
Dim cutoffDate As DatecutoffDate = (ActiveSheet.Cells(1, 2).Value)
i = Cells(Rows.Count, 1).End(xlUp).Row+ 1
Dim FileFor Each File In Folder.Files
If FileDateTime(File.Path) > cutoffDate Then ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 1), Address:= _
File.Path, TextToDisplay:=File.Name ActiveSheet.Cells(i, 2).Value = FileDateTime(File.Path)
End If
i + 1
Next
Columns.AutoFit
End Sub
Posted by: Taurean KV <taureankv@gmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar