A
Ayo
I am getting a variable not defined error on this line "For Each c In
lstrng.Cells" and I can't figure out what that means. Any ideas?
Set lstrng = Range("A2:A" & Range("A2").End(xlDown).Row)
Set fs = Application.FileSearch
'Use Microsoft Scripting runtime.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.getFolder(UserForm1.txtFolder.Value)
'Check type of file in the folder and open file.
For Each c In lstrng.Cells
c.Activate
If c <> "" Then
With fs
.LookIn = f
.SearchSubFolders = True
.Filename = c.Value
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
c.Offset(0, i + 1).Value = .FoundFiles(i)
Next i
Else
'MsgBox "There were no files found."
End If
End With
ElseIf c = "" Then
Exit For
End If
Next
lstrng.Cells" and I can't figure out what that means. Any ideas?
Set lstrng = Range("A2:A" & Range("A2").End(xlDown).Row)
Set fs = Application.FileSearch
'Use Microsoft Scripting runtime.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.getFolder(UserForm1.txtFolder.Value)
'Check type of file in the folder and open file.
For Each c In lstrng.Cells
c.Activate
If c <> "" Then
With fs
.LookIn = f
.SearchSubFolders = True
.Filename = c.Value
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
c.Offset(0, i + 1).Value = .FoundFiles(i)
Next i
Else
'MsgBox "There were no files found."
End If
End With
ElseIf c = "" Then
Exit For
End If
Next