Keebellah,
I figured out my add on question using your split method, but this time I just split the File Name only so I did not have to worry about multiple parameters. Thanks a lot for the help on the split function I had not used that before.
Final code is below
Sub RecursiveFolder(objFolder As Scripting.Folder, IncludeSubFolders As Boolean)
'Declare the variables
Dim objFile As Scripting.File
Dim objSubFolder As Scripting.Folder
Dim NextRow As Long, lr As Long, Filename As Range
Dim ws1 As Worksheet, NewFile As Range
Dim Foldstring As String, Namestring As String, foldArr As Variant, nameArr As Variant
Set ws1 = ThisWorkbook.Sheets("Sheet1")
lr = ws1.Range("B" & Rows.Count).End(xlUp).Row
Set Filename = ws1.Range("B2:B" & lr)
'Find the next available row
NextRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
'Loop through each file in the folder
For Each objFile In objFolder.Files
With ws1.Range("B2:B" & lr)
Set NewFile = .Find(What:=objFile.Name, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If NewFile Is Nothing Then
Namestring = objFile.Name
nameArr = (Split(Namestring, " - "))
ws1.Cells(NextRow, "E").Value = nameArr(LBound(nameArr))
ws1.Cells(NextRow, "B").Value = objFile.Name
ws1.Cells(NextRow, "B").Select
ws1.Hyperlinks.Add Anchor:=Selection, Address:=(objFile.Path), TextToDisplay:=Selection.Text
Foldstring = objFile.Path
foldArr = (Split(Foldstring, "\"))
ws1.Cells(NextRow, "C").Value = foldArr(LBound(foldArr) + 8) 'objFolder.Name
ws1.Cells(NextRow, "D").Value = foldArr(LBound(foldArr) + 7) 'objFolder.ParentFolder.Name
NextRow = NextRow + 1
End If
End With
Next objFile
'Loop through files in the subfolders
If IncludeSubFolders Then
For Each objSubFolder In objFolder.SubFolders
Call RecursiveFolder(objSubFolder, True)
Next objSubFolder
End If
Call Sort
End Sub
Bookmarks