Could you please help me to solve this issue?
This loop for my macro shows me 'run time error 1004' in Line 16.
Sub Macro_data_L3()
' Set folder containing CSV files
Const strFOLD As String = "C:\Users\XX\Desktop\"
' Set formula to be used
Const strFORMULA As String = "GET.DOCUMENT(88)"
Dim strFile As String
Dim wkbCsv As Workbook
Dim lngLastRow As Long
strFile = Dir$(strFOLD & "*.csv", vbNormal)
Do While strFile <> vbNullString
Set wkbCsv = Application.Workbooks.Open(Filename:=strFile)
With wkbCsv.Worksheets(1)
.Rows("1").Delete
With .Columns("B")
.Clear
.Insert
End With
.Columns("A").TextToColumns _
Destination:=.Range("A1"), _
Other:=True, _
OtherChar:=Chr(47), _
FieldInfo:=Array( _
Array(1, xlGeneralFormat), _
Array(2, xlGeneralFormat), _
Array(3, xlGeneralFormat))
.Columns("A:C").ClearFormats
.Range("A1:C1").Value = Array("Day", "Month", "Year")
.Columns("C").Cut
.Columns("A").Insert
.Columns("B").Cut
.Columns("D").Insert
.Columns("A").Insert
.Range("A1").Value = "ID"
lngLastRow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A2:A" & lngLastRow).Formula = _
"=SUBSTITUTE(" & strFORMULA & ", "".CSV"", """")"
strFile = Dir$()
End With
Loop
End Sub
Bookmarks