Holger,
The loop worked perfectly. Thank you for all your help.
For completeness, here is my final code that works.
Sub Macro1()
'
' Macro1 Macro
'
'
Dim sFile As String
Dim spath As String
Dim wB As Workbook
Dim wS As Worksheet
spath$ = "C:\Users\User\Desktop\1LES95\small loop test\"
Set wB = Workbooks.Add
Set wS = wB.Sheets(1)
sFile$ = Dir(spath & "1*.csv")
'sFile = "1les95A1.csv"
Do Until sFile = ""
If Right(sFile, 4) <> ".csv" Then
With wB.Sheets(1).QueryTables.Add(Connection:= _
"TEXT;" & spath & sFile _
, Destination:=Range("A1"))
.Name = sFile
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileFixedColumnWidths = Array(16, 16)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
wB.SaveAs Filename:=spath & "A" & sFile _
, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
wS.Cells.ClearContents
Application.DisplayAlerts = True
End If
sFile$ = Dir
Loop
End Sub
Bookmarks