提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何在Excel中快速批量导入多个csv / text / xml文件?

在Excel中,您可能已经将工作簿保存为csv文件,文本文件或xml文件,但您是否尝试过将多个csv / text / xml文件从文件夹导入工作簿或工作表? 在这篇文章中,我介绍一些快速批量导入它们的方法。

使用VBA将文件夹中的多个文本文件导入到工作簿的每个工作表中

使用VBA将多个csv文件从一个文件夹导入到一个工作表中

使用VBA将多个xml文件从一个文件夹导入到一个工作表中

使用Kutools for Excel将多个xml / csv文件导入或合并到工作表或工作簿中 好idea3

将每张纸以csv / text / pdf导出到Kutools for Excel文件夹好idea3


轻松将多个工作表/工作簿合并到一张工作表或工作簿中

将多个工作表或工作簿合并到一个工作表或工作簿中可能在Excel中很有用,但使用 结合 功能在Kutools for Excel中,您可以将合并几十张工作表/工作簿合并到一张工作表或工作簿中,而且,只能通过几次点击将工作表合并到一个工作表中。 点击查看功能齐全的60天免费试用版!
结合床单
Kutools for Excel:拥有超过300便利的Excel加载项,可以在60天免费试用,不受限制。
Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel - 最佳办公生产力工具将解决您的大部分Excel问题
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 适用于Office 2007-2019和365; 支持所有语言; 在公司轻松部署; 全功能60天免费试用。


要将文件夹中的文本文件导入到工作簿,可以使用下面的VBA快速处理它。

1。 启用空白工作簿,然后按 Alt + F11键 键打开 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块,并将VBA粘贴到 模块 窗口。

VBA:将文件夹中的所有文本文件导入工作簿

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。 按 F5 键或 按钮来运行VBA,然后从弹出对话框中选择一个要从中导入文本文件的文件夹。 看截图:

doc导入多个csv文本xml 1

4。 然后点击 OK,并且所选文件夹中的每个文本文件都已导入到活动工作簿的一个工作表中。 看截图:

doc导入多个csv文本xml 2doc导入多个csv文本xml 3

要将所有csv文件从一个文件夹导入到一张表中,可以使用下面的VBA代码。

1。 启用空白工作表,然后按 Alt + F11键 键打开 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块,并将VBA粘贴到新的 模块 窗口。

VBA:将csv文件从一个文件夹导入到一个工作表中

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。 按 F5 键或点击 按钮来执行VBA,并弹出一个对话框来选择要导入所有csv文件的文件夹。 看截图:

doc导入多个csv文本xml 4

4。 点击 OK,弹出一个对话框提醒你是否在导入之前清除活动工作表的内容,这里点击。 看截图:

doc导入多个csv文本xml 5

点击后 ,所选文件夹中的所有csv文件都将导入到当前工作表中,并将列A中的数据放置到右侧。 看截图:

doc导入多个csv文本xml 6doc导入多个csv文本xml 7

提示: 如果要将csv文件水平放置在工作表中,可以使用下面的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导入多个csv文本xml 8


如果要将文件夹中的所有XML文件导入到一张表中,则可以使用下面的VBA代码。

1。 选择要放置导入数据的空白工作表,然后按 Alt + F11键 键启用 Microsoft Visual Basic for Applications 窗口。

2。 点击 插页 > 模块,将VBA代码粘贴到 模块 窗口。

VBA:将XML文件从一个文件夹导入工作表。

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。 点击 按钮或 F5 键来运行VBA,并在弹出对话框中选择一个文件夹,看截图:

doc导入多个csv文本xml 9

4。 点击 OK,并将所选文件夹中的所有XML文件导入活动工作表。


如果您对VBA不熟悉,请担心,在这里我介绍一个方便的工具 - Kutools for Excel 为你。 凭借其强大 结合 实用程序,您可以将多个xml文件或csv文件快速合并到一个工作簿或一个Excel工作表中。

Kutools for Excel, 与超过 300 方便的功能,让您的工作更轻松。

安装后 Kutools for Excel,请按照以下步骤操作:(免费下载Kutools for Excel!)

1。 激活Excel,然后单击 企业服务 > 结合。 看截图:
doc结合1

2。 而在中 组合的步骤1 对话框中,根据需要选择一个分隔选项。 看截图:
doc结合2

3。 点击 下一步组合的步骤2,单击“ 添加 从各个文件夹或文件从一个文件夹添加文件 工作簿 列表,还可以指定要合并的工作表 工作表 右侧部分的列表。 看截图:
doc结合3

4。 点击 下一步 到最后一步 结合,你可以指定选项。

1)指定标题行号

2)决定是否插入工作表信息

3)是否跳过空白范围

4)指定粘贴选项
doc结合4

5。 点击弹出一个对话框提醒您选择一个位置来保存新的合并结果。 看截图:
doc结合5

6。 点击 保存。 所有添加的工作表已合并成一个新的单一工作表。
doc结合6

提示: 您订购的 结合,你也可以结合多个 CSV文件 形成多个文件夹或一个文件夹到一个工作表或工作簿。


如果你想把每张纸以csv / text / pdf格式导出到一个文件夹, Kutools for Excel分割工作簿 实用程序可以帮你一个忙。

免费安装 Kutools for Excel,请按照以下步骤操作:

1。 启用要导出其工作表的工作簿,然后单击 企业服务 > 工作簿 > 分割工作簿。 看截图:

doc导入多个csv文本xml 10

2。 在里面 分割工作簿 对话框中,您可以检查需要导出的图纸名称,默认情况下所有的图纸都会被检查并检查 指定保存格式 并从下拉列表中选择要保存的文件格式。 看截图:

doc导入多个csv文本xml 11

3。 点击 分裂 并选择一个文件夹来保存分割文件 浏览文件夹 对话框,看截图:

doc导入多个csv文本xml 12

4。 点击 OK,现在所有选中的工作表都将以选定文件夹中的新文件格式导出。


快速转换多个XLSX。 文件到XLS或PDF。 文件在一次

在许多情况下,您可能希望在XLSX和XLS之间进行转换,或者将工作簿转换为PDF文件,但是在Excel中,只能转换一个工作簿一次,您是否曾经映像过一次转换多个工作簿? 同 Kutools for Excel's File Format Converter,您可以立即将多个工作簿快速转换为pdf / 97-2003工作簿/ 2007或更高版本的工作簿,并将其保存在一个文件夹中,同时生成一个转换后的报表! 点击60天免费试用!
doc文件转换器
Kutools for Excel:拥有超过300便利的Excel加载项,可以在60天免费试用,不受限制。

相关文章:


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
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 · 3 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 · 4 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 · 3 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 · 6 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!