hello experts,
i have this macro to open a number of csv files. Problem is that it opens all the files in one worksheet. Could you add a few lines to the macro to open them in separate worksheets of the excel file. i would be grateful for the help.
Thanks
i have this macro to open a number of csv files. Problem is that it opens all the files in one worksheet. Could you add a few lines to the macro to open them in separate worksheets of the excel file. i would be grateful for the help.
Thanks
HTML:
Sub BulkImport()'' BulkImport Macro
Dim nxt_row As Long 'Change Path Const strPath As String = "C:\My Documents\IEOD\" '"ENTER FILE PATH HERE WITH A TRAILING \ e.g: C:\Test\" Dim strExtension As String 'Stop Screen Flickering Application.ScreenUpdating = False ChDir strPath 'Change extension strExtension = Dir(strPath & "*.txt") Do While strExtension <> "" 'Adds File Name as title on next row Range("A65536").End(xlUp).Offset(1, 0).Value = strExtension 'Sets Row Number for Data to Begin nxt_row = Range("A65536").End(xlUp).Offset(1, 0).Row 'Below is from a recorded macro importing a text file With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;" & strPath & strExtension, Destination:=Range("$A$" & nxt_row)) .Name = strExtension .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .TextFilePromptOnRefresh = False .TextFilePlatform = 850 .TextFileStartRow = 1 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote 'Delimiter Settings: .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = True .TextFileCommaDelimiter = True .TextFileSpaceDelimiter = True .TextFileOtherDelimiter = "=" .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With strExtension = Dir Loop Application.ScreenUpdating = True 'End Sub