Hi all,
I have this line of code that gathers data from specified files with certain names in a list. I think I have everything I need but it comes up with
and highlights
The full thing is here
Any help is appreciated
Thanks in advance
I have this line of code that gathers data from specified files with certain names in a list. I think I have everything I need but it comes up with
Code:
Runtime error 424 Object required
Code:
for each objfile in objfiles
Code:
Sub Test()
Dim sFolder As String
Application.ScreenUpdating = True
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a folder..."
.Show
If .SelectedItems.Count > 0 Then
sFolder = .SelectedItems(1) & "\"
Else
Exit Sub
End If
End With
Call Consolidate(sFolder, ThisWorkbook)
End Sub
Private Sub Consolidate(sFolder As String, wbMaster As Workbook)
Dim wbTarget As Workbook
Dim objFso As Object
Dim ary(3) As Variant
Dim lRow As Long
Dim objFiles As Object
Dim objFile As Object
Dim CodeNames As Variant, i As Long
CodeNames = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row)
For Each objFile In objFiles
For i = 1 To UBound(CodeNames, 1)
If objFile.Name Like "*" & CodeNames(i, 1) & "*" Then
'get data from the file
Exit For
End If
Next i
Next objFile
End Sub
Any help is appreciated
Thanks in advance