You could try someting like this, not absolutely sure as I've not tested it.
Option Explicit
Sub ExtrFil()
Dim sPath As String
Dim fName As String
Application.ScreenUpdating = False
sPath = "C:\Users\mpiet\Documents\Computer Inventory\Logs\"
fName = Dir("C:\Users\mpiet\Documents\Computer Inventory\Logs\*.csv")
Do While Len(fName) > 0
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = Mid(fName, 1, Len(fName) - 4)
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPath & fName, Destination:=Range("$A$1"))
.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 = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
fName = Dir
Loop
Application.ScreenUpdating = True
End Sub
Managed to test the code and it works ok. Made two minore changes. All new sheets will be added at the end in the workbook and the tab name for the sheet will be the file name minus the ".csv" part. Hopefully you have too many letters in the csv file name as there is a limit to the length of the tab name.
Alf
Bookmarks