Sub Update_Data()
List_Man_Acc_FileNames
Copy_ListFiles
Delete_Row
Open_Files
Export_TB
Dim DataObj As New MSForms.DataObject 'empty the clipboard
DataObj.SetText ""
DataObj.PutInClipboard
End Sub
Sub List_Man_Acc_FileNames()
Sheets("file names").Range("A1:C150").ClearContents
Application.ScreenUpdating = False
Sheets("file names").Range("A1:C1").Value = Array("File Name", "Created", "Last Modified")
LoopController ("C:\pull")
Sheets("file names").Columns.AutoFit
End Sub
Private Sub LoopController(sSourceFolder As String)
'This will loop into itself, first processing the files in the folder
'then looping into each subfolder deeper and deeper until all folders processed
Dim Fldr As Object, FL As Object, SubFldr As Object
Call ListFilesinFolder(sSourceFolder & Application.PathSeparator)
Set Fldr = CreateObject("Scripting.FileSystemObject").GetFolder(sSourceFolder)
For Each SubFldr In Fldr.SubFolders
LoopController SubFldr.path
Next
End Sub
Sub ListFilesinFolder(MyPath As String)
Dim FSO As Object, f As Object, FLD As Object, NR As Long
NR = Sheets("file names").Range("A" & Rows.Count).End(xlUp).Row
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FLD = FSO.GetFolder(MyPath).Files
For Each f In FLD
If InStr(f.Name, "ACCNTS(P)") > 0 And Right(f.Name, 4) = ".xls" Then
NR = NR + 1
Sheets("file names").Range("A" & NR).Value = f.Name
Sheets("file names").Range("B" & NR).Value = f.DateCreated
On Error Resume Next
Sheets("file names").Range("C" & NR).Value = f.DateLastModified
On Error GoTo 0
End If
Next f
End Sub
Sub Copy_ListFiles()
With Sheets("Workspace")
.Range("A1:A50").ClearContents
End With
Dim LR As Long
With Sheets("File names")
LR = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("A2:A" & LR).Copy
End With
With Sheets("Workspace")
.Range("A1").PasteSpecial Paste:=xlPasteValues
End With
Application.CutCopyMode = False
End Sub
Sub Replace_Data()
Sheets("Workspace").Select
Dim LR As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row
With Range("A1:A" & LR)
.Replace What:=".xls", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End With
End Sub
Sub Delete_Row()
With Sheets("Workspace")
Dim LR As Long, I As Long
LR = .Cells(Rows.Count, "A").End(xlUp).Row 'last row
For I = LR To 1 Step -1
If .Cells(I, "A") Like "[Bb][Rr]" Then Rows(I).Delete
Next I
End With
End Sub