Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to quickly batch import multiple csv/text/xml files in Excel?

In Excel, you may have tied to save a workbook as csv file, text file or xml file, but have you ever tried to import multiple csv/text/xml files from a folder into a workbook or a worksheet? In this article, I introduce some methods to quickly batch import them.

Import multiple text files from a folder into each worksheets of a workbook with VBA

Import multiple csv files from a folder into a single sheet with VBA

Import multiple xml files from a folder into a single sheet with VBA

Import or combine multiple xml/csv files into a sheet or a workbook with Kutools for Excel good idea3

Export each sheet as csv/text/pdf to a folder with Kutools for Excelgood idea3


Easily Combine multiple sheets/Workbook into one Single sheet or Workbook

To combinne multiples sheets or workbooks into one sheet or workbook may be edious in Excel, but with the Combine function in Kutools for Excel, you can combine merge dozens of sheets/workbooks into one sheet or workbook, also, you can consolidate the sheets into one by several clicks only.  strong>Click for full-featured 30 days free trial!
combine sheets
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.
Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words...
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum...
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns...
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Create Mailing List and Send Emails by Cell's Value...
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.


To import text files from a folder to a workbook, you can use below VBA to quickly handle it.

1. Enable a blank workbook, and press Alt + F11 keys to open Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the VBA to the Module window.

VBA: Import all text files from a folder into a workbook

Sub LoadPipeDelimitedFiles()
'UpdatebyKutoolsforExcel20151214
    Dim xStrPath As String
    Dim xFileDialog As FileDialog
    Dim xFile As String
    Dim xCount As Long
    On Error GoTo ErrHandler
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    xFileDialog.AllowMultiSelect = False
    xFileDialog.Title = "Select a folder [Kutools for Excel]"
    If xFileDialog.Show = -1 Then
        xStrPath = xFileDialog.SelectedItems(1)
    End If
    If xStrPath = "" Then Exit Sub
    Application.ScreenUpdating = False
    xFile = Dir(xStrPath & "\*.txt")
    Do While xFile <> ""
        xCount = xCount + 1
        Sheets(xCount).Select
        With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
          & xStrPath & "\" & xFile, Destination:=Range("A1"))
            .Name = "a" & xCount
            .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 = False
            .TextFileSpaceDelimiter = False
            .TextFileOtherDelimiter = "|"
            .TextFileColumnDataTypes = Array(1, 1, 1)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
            xFile = Dir
        End With
    Loop
    Application.ScreenUpdating = True
    Exit Sub
ErrHandler:
    MsgBox "no files txt", , "Kutools for Excel"
End Sub

3. Press F5 key or Run button to run the VBA, and select a folder that you want to import the text files from in the popping dialog. See screenshot:

doc import multiple csv text xml 1

4. And click OK, and each text file in the selected folder has been imported into one worksheet of the active workbook. See screenshot:

doc import multiple csv text xml 2doc import multiple csv text xml 3

To import all the csv files form a folder into a single sheet, you can use below VBA code.

1. Enable a blank worksheet, and press Alt + F11 keys to open Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste below VBA into the new Module window.

VBA: Import csv files from a folder into one worksheet

Sub ImportCSVsWithReference()
'UpdatebyKutoolsforExcel20151214
    Dim xSht  As Worksheet
    Dim xWb As Workbook
    Dim xStrPath As String
    Dim xFileDialog As FileDialog
    Dim xFile As String
    On Error GoTo ErrHandler
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    xFileDialog.AllowMultiSelect = False
    xFileDialog.Title = "Select a folder [Kutools for Excel]"
    If xFileDialog.Show = -1 Then
        xStrPath = xFileDialog.SelectedItems(1)
    End If
    If xStrPath = "" Then Exit Sub
    Set xSht = ThisWorkbook.ActiveSheet
    If MsgBox("Clear the existing sheet before importing?", vbYesNo, "Kutools for Excel") = vbYes Then xSht.UsedRange.Clear
    Application.ScreenUpdating = False
    xFile = Dir(xStrPath & "\" & "*.csv")
    Do While xFile <> ""
        Set xWb = Workbooks.Open(xStrPath & "\" & xFile)
        Columns(1).Insert xlShiftToRight
        Columns(1).SpecialCells(xlBlanks).Value = ActiveSheet.Name
        ActiveSheet.UsedRange.Copy xSht.Range("A" & Rows.Count).End(xlUp).Offset(1)
        xWb.Close False
        xFile = Dir
    Loop
    Application.ScreenUpdating = True
    Exit Sub
ErrHandler:
    MsgBox "no files csv", , "Kutools for Excel"
End Sub

3. Press F5 key or click Run button to execute the VBA, and a dialog pops out to select a folder that you want to import all csv files from. See screenshot:

doc import multiple csv text xml 4

4. Click OK, and a dialog pops out to remind you if clear the contents of active worksheet before importing, here I click Yes. See screenshot:

doc import multiple csv text xml 5

After clicking Yes, all csv files in the selected folder are imported into the current sheet, and place data from Column A to right. See screenshot:

doc import multiple csv text xml 6doc import multiple csv text xml 7

Tip: If you want to place csv files horizontally in a worksheet, you can use below VBA.

Sub ImportCSVsWithReferenceI()
'UpdatebyKutoolsforExcel20151214
    Dim xSht  As Worksheet
    Dim xWb As Workbook
    Dim xStrPath As String
    Dim xFileDialog As FileDialog
    Dim xFile As String
    Dim xCount As Long
    On Error GoTo ErrHandler
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    xFileDialog.AllowMultiSelect = False
    xFileDialog.Title = "Select a folder [Kutools for Excel]"
    If xFileDialog.Show = -1 Then
        xStrPath = xFileDialog.SelectedItems(1)
    End If
    If xStrPath = "" Then Exit Sub
    Set xSht = ThisWorkbook.ActiveSheet
    If MsgBox("Clear the existing sheet before importing?", vbYesNo, "Kutools for Excel") = vbYes Then
        xSht.UsedRange.Clear
        xCount = 1
    Else
        xCount = xSht.Cells(3, Columns.Count).End(xlToLeft).Column + 1
    End If
    Application.ScreenUpdating = False
    xFile = Dir(xStrPath & "\" & "*.csv")
    Do While xFile <> ""
        Set xWb = Workbooks.Open(xStrPath & "\" & xFile)
        Rows(1).Insert xlShiftDown
        Range("A1") = ActiveSheet.Name
        ActiveSheet.UsedRange.Copy xSht.Cells(1, xCount)
        xWb.Close False
        xFile = Dir
        xCount = xSht.Cells(3, Columns.Count).End(xlToLeft).Column + 1
    Loop
    Application.ScreenUpdating = True
    Exit Sub
ErrHandler:
    MsgBox "no files csv", , "Kutools for Excel"
End Sub 

doc import multiple csv text xml 8


If you want to import all XML files from a folder into a single sheet, you can use below VBA code.

1. Select a blank sheet you want to place the imported data, and press Alt + F11 keys to enable Microsoft Visual Basic for Applications window.

2. Click Insert > Module, paste VBA code into the Module window.

VBA: Import XML files from a folder into a worksheet.

Sub From_XML_To_XL()
'UpdatebyKutoolsforExcel20151214
    Dim xWb As Workbook
    Dim xSWb As Workbook
    Dim xStrPath As String
    Dim xFileDialog As FileDialog
    Dim xFile As String
    Dim xCount As Long
    On Error GoTo ErrHandler
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    xFileDialog.AllowMultiSelect = False
    xFileDialog.Title = "Select a folder [Kutools for Excel]"
    If xFileDialog.Show = -1 Then
        xStrPath = xFileDialog.SelectedItems(1)
    End If
    If xStrPath = "" Then Exit Sub
    Application.ScreenUpdating = False
    Set xSWb = ThisWorkbook
    xCount = 1
    xFile = Dir(xStrPath & "\*.xml")
    Do While xFile <> ""
        Set xWb = Workbooks.OpenXML(xStrPath & "\" & xFile)
        xWb.Sheets(1).UsedRange.Copy xSWb.Sheets(1).Cells(xCount, 1)
        xWb.Close False
        xCount = xSWb.Sheets(1).UsedRange.Rows.Count + 2
        xFile = Dir()
    Loop
    Application.ScreenUpdating = True
    xSWb.Save
    Exit Sub
ErrHandler:
    MsgBox "no files xml", , "Kutools for Excel"
End Sub

3. Click Run button or F5 key to run the VBA, and select a folder in the popping dialog, see screenshot:

doc import multiple csv text xml 9

4. Click OK, and all the XML files in the selected folder are imported into the active sheet.


If you are not familiar with VBA, do worry, here I introduce a handy tool – Kutools for Excel for you. With its powerful Combine utility, you can quickly combine multiple xml files or csv files into one workbook or one Excel sheet.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

1. Active Excel, and click Enterprise > Combine. See screenshot:
doc combine 1

2. And in the step 1 of Combine dialog, choose one separation option as you need. See screenshot:
doc combine 2

3. Click Next to go to step 2 of the Combine, click Add to add files from various folders or files from one folder to Workbook list, and also you can specify the sheets you want to combine from Worksheet list of right section. See screenshot:
doc combine 3

4. Click Next to the last one step of Combine, and you can specify the options.

1) Specify the title row number

2) Decide if insert worksheet information

3) Skip blank range or not

4) Specify paste option
doc combine 4

5. Click Finish, a dialog pops out to remind you select a location to save the new combined result. See screenshot:
doc combine 5

6. Click Save. All adding sheets have been combine into a new single sheet.
doc combine 6

Tip: With Combine, you also can combine multiple CSV files form multiple folders or one folder into one sheet or workbook.


If you want to export each sheet as csv/text/pdf file to a folder, Kutools for Excel’s Split Workbook utility can do a favor for you.

After free installing Kutools for Excel, please do as below:

1. Enable the workbook you want to export its worksheets, and click Enterprise > Workbook > Split Workbook. See screenshot:

doc import multiple csv text xml 10

2. In the Split Workbook dialog, you can check the sheet names you need to export, in default all the sheets are checked, and check Specify save format and select the file format you want to save as from below drop down list. See screenshot:

doc import multiple csv text xml 11

3. Click Split and select a folder that to save the split files in the Browse for Folder dialog, see screenshot:

doc import multiple csv text xml 12

4. Click OK, now all the checked sheets are exported as new file format in the selected folder.


quickly convert multiple XLSX. files to XLS or PDF. files in once time

In many cases, you may want to convert between XLSX and XLS, or convert a workbook to PDF file, but in Excel, you only can convert one workbook once time, have you ever imaged to convert multiple workbooks at once time? With Kutools for Excel's File Format Converter, you can quickly convert multiple workbook to pdf/97-2003 workbook/2007 or higher workbook at once and save them in a folder, at the same time, a converted report is generated!  Click for 60 days free trial!
doc file converter
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

Relative Articles:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Marshall Treynor · 4 months ago
    Hello - I've used your VBA codes to extract data from multiple CSV files to excel file (the code on this page) and convert csv files to excel files ( this one: https://www.extendoffice.com/documents/excel/4615-excel-batch-convert-csv-to-xls-xlsx.html), with great results. They helped me save a lot of time.

    However, I notice a common problem with both of these types of codes. To clarify, my system is set up to use the European standards for dates, while some of the CSV files I received for my work contain dates in US standards. The first problem is, when I extract or convert data from a CSV file that contains dates in US format, all of those dates are reversed (matching the EU standards used by my system). This is great but it also caused me troubles since I didn't know the codes would reverse the dates for me, so I went on ahead and did the same thing again. The second problem is, for the CSV files that contain dates already in the same format as the one used by my system (EU standards), only the ambiguous dates are reversed (i.e 04/05/2019 - 05/04/2019), while the ones that are too obvious, remain unchanged (i.e 30/04/2019).

    What I would like the codes to do, is the exact same thing as they are shown here, only that they should copy and paste the data (especially dates) in the exact formats used in the original files. This would help prevent any possible confusions and mistakes. I would like to learn VBA so I can one day write my own codes, but for now, I'm not even able to modify parts of the existing codes to suit my needs. So if you can help, please tell me where I should put the modified codes (that you come up with) to the existing codes. I appreciate all feedback & support I can get. Thank you all!
  • To post as a guest, your comment is unpublished.
    Scott W · 5 months ago
    Hi - I'm using the import all csv files into one file listed above "Import Multiple Csv Files From A Folder Into A Single Sheet With VBA"- i'd like to define the folder it collects the data from without having to manually choose it. Can this be done? thanks - SW.
    • To post as a guest, your comment is unpublished.
      Sunny · 4 months ago
      Hi, Scott W, I found a VBA code may can help you.
      Option Explicit

      Sub ImportCSVsWithReference()
      'Author: Jerry Beaucaire
      'Date: 10/16/2010
      'Summary: Import all CSV files from a folder into a single sheet
      ' adding a field in column A listing the CSV filenames

      Dim wbCSV As Workbook
      Dim wsMstr As Worksheet: Set wsMstr = ThisWorkbook.Sheets("Sheet1")
      Dim fPath As String: fPath = " C:\Users\DT168\Desktop\New folder\" 'path to CSV files, include the final \
      Dim fCSV As String

      If MsgBox("Clear the existing sheet before importing?", vbYesNo, "Clear?") _
      = vbYes Then wsMstr.UsedRange.Clear

      Application.ScreenUpdating = False 'speed up macro

      fCSV = Dir(fPath & "*.csv") 'start the CSV file listing

      Do While Len(fCSV) > 0
      'open a CSV file
      Set wbCSV = Workbooks.Open(fPath & fCSV)
      'insert col A and add CSV name
      Columns(1).Insert xlShiftToRight
      Columns(1).SpecialCells(xlBlanks).Value = ActiveSheet.Name
      'copy date into master sheet and close source file
      ActiveSheet.UsedRange.Copy wsMstr.Range("A" & Rows.Count).End(xlUp).Offset(1)
      wbCSV.Close False
      'ready next CSV
      fCSV = Dir
      Loop

      Application.ScreenUpdating = True
      End Sub
  • To post as a guest, your comment is unpublished.
    Jake Howard · 7 months ago
    Thank you. This site has been a big help. I have one issue I cannot figure out. I am trying to import multiple csv files into an excel separate sheets in excel and have each sheet renamed after the file name of the csv file. I know this was covered below for a txt file but I am working with csv files. Thanks in advance.
  • To post as a guest, your comment is unpublished.
    Shea · 1 years ago
    Hi! I used the code to merge multiple XML files into one, but unfortunately the columns got messed up. The 5 files being merged all had the same format. Is there anyway to fix this? I also was wondering if there was a way to get rid of the headers that are duplicated when the files are merged. Thank you!
  • To post as a guest, your comment is unpublished.
    Ramy Zahran · 1 years ago
    i have code to import txts to sheets each txt to each sheet, but i want every txt be imported with its name to sheet , i mean rename every imported sheet with the name of the txt the code file attatched .. thanks
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Hello, Ramy, zahran, you can try below code which can import the text files and rename the sheet name to the text file name.
      Sub LoadPipeDelimitedFiles()
      'UpdatebyExtendoffice20180925
      Dim xStrPath As String
      Dim xFileDialog As FileDialog
      Dim xFile As String
      Dim xCount As Long
      Dim xWS As Worksheet

      On Error GoTo ErrHandler
      Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
      xFileDialog.AllowMultiSelect = False
      xFileDialog.title = "Select a folder [Kutools for Excel]"
      If xFileDialog.Show = -1 Then
      xStrPath = xFileDialog.SelectedItems(1)
      End If
      If xStrPath = "" Then Exit Sub
      Application.ScreenUpdating = False
      xFile = Dir(xStrPath & "\*.txt")
      Do While xFile <> ""
      xCount = xCount + 1
      Set xWS = Sheets(xCount)
      xWS.Select
      xWS.Name = "TEXT " & Left(xFile, Len(xFile) - 4)
      With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
      & xStrPath & "\" & xFile, Destination:=Range("A1"))
      .Name = "a" & xCount
      .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 = False
      .TextFileSpaceDelimiter = False
      .TextFileOtherDelimiter = "|"
      .TextFileColumnDataTypes = Array(1, 1, 1)
      .TextFileTrailingMinusNumbers = True
      .Refresh BackgroundQuery:=False
      xFile = Dir
      End With
      Loop
      Application.ScreenUpdating = True
      Exit Sub
      ErrHandler:
      MsgBox "no files txt", , "Kutools for Excel"
      End Sub
  • To post as a guest, your comment is unpublished.
    rendy · 1 years ago
    hello, saya mau tanya kalo impor txt file ke satu sheet gimana ya?
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Hello, rendy, would you want to import all txts to one sheet or each txt to each sheet?
      • To post as a guest, your comment is unpublished.
        Ramy Zahran · 1 years ago
        i have code to import txts to sheets each txt to each sheet, but i want every txt be imported with its name to sheet , i mean rename every imported sheet with the name of the txt the code file attatched .. i want to edit this file to add code for renaming sheets with txts name ... thanks.
  • To post as a guest, your comment is unpublished.
    Hey · 1 years ago
    It worked! Thanks
  • To post as a guest, your comment is unpublished.
    Amanda · 1 years ago
    Hello, I tried running the code for .xml and it didn't appear to work as I got the message "no files xml". How do fix this?
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      It will pop a message"no files xml" while your selected folder do not contain the xml files. You can select the right folder which contains xml files in popping dialog after run the code for importing them to the active sheet.
  • To post as a guest, your comment is unpublished.
    see · 1 years ago
    Totally amazing! Tried the open all csv files in one worksheet and it worked beautifully. Thanks so much, really!
  • To post as a guest, your comment is unpublished.
    Chad · 1 years ago
    Mike: "the code for converting from txt files did not work for me."

    I had the same problem.The macro errors out if you have more txt files to open than worksheets in your workbook (default is 3).
    I fixed it by adding the following just before the loop exits so the macro creates a new sheet after the rest
    ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
    • To post as a guest, your comment is unpublished.
      AJ · 1 years ago
      Chad, This perfectly worked for me to import multiple text files. Thank you.

      Do you know if there is a way to pull the file names? I want the text file names copied into each excel sheet tabs.
  • To post as a guest, your comment is unpublished.
    zoi · 1 years ago
    Hi! The code "Import csv files from a folder into one worksheet", works for me! But this code doesn't work for an empty .txt file. Is there any way to keep also the empty files?
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Sorry, I do not know why need to import an empty txt.file~Just insert blank rows to seperate the contents.
  • To post as a guest, your comment is unpublished.
    Mike · 1 years ago
    the code for converting from txt files did not work for me.
    • To post as a guest, your comment is unpublished.
      Sunny · 1 years ago
      Sorry this article do not work for you. Could you describe you problem? What happen while runing the code? And what system you work?
  • To post as a guest, your comment is unpublished.
    Patrick · 2 years ago
    Problem with this is that it the VBA command nor Kutools allows to import the csv files with character code formating. The preload is western. I need to import all the csv files as unicode-8
  • To post as a guest, your comment is unpublished.
    Abdissattar · 2 years ago
    Hi,I would like to understand about the VBA code for "Importing Multiple .txt files from a folder to a single sheet with VBA " by next available row (not horizontal). Please help,urgent
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Hello, if you want to import all txt files from one folder to a single sheet, you can using the above vba code to import txt files to a workbook first, then apply Kutools for Excel's Combine Worksheets feature to combine all sheets of a workbook to one sheet, then the txt files in a sheet. Hope it helps u.
  • To post as a guest, your comment is unpublished.
    XY · 2 years ago
    Hi,

    I would like to understand about the VBA code for "Import Multiple Xml Files From A Folder Into A Single Sheet With VBA".
    1. Why are 2 workbooks needed instead of 1?
    2. It is taking some time to load many xml files into excel, so is there a more efficient code? Because i realise when your code was run, many VBA workbook is created which caused the slowdown.

    I would really appreciate if you can help me to understand!
    • To post as a guest, your comment is unpublished.
      Sunny · 2 years ago
      Sorry, I did not understand ur first one question, and about the second one, the more effeicent code, I have not found it, if you know, please leave a note for me, thanks.
  • To post as a guest, your comment is unpublished.
    Thomas · 2 years ago
    Hi there, thank you very much for those code samples! The first one (VBA: Import all text files from a folder into a workbook) is almost exactly what I need. I would like, however, to select which files to import and not automatically import all the text files in any given folder. I would also like the exiting contents of my target sheets to be overwritten by the contents of the text files. (With the code above, the existing contents is shifted to the right instead of being replaced.)
    How do I go about that?
    Thanks in advance!