【问题标题】:import to excel a text file using cell value使用单元格值导入到 Excel 文本文件
【发布时间】:2012-06-11 06:45:03
【问题描述】:

我有一些 .txt 输出文件想要导入到 excel 中。

理想情况下,我想使用 Sheet1 作为索引;我将在其中写下标题、工作表名称以及 .txt 文件的路径和名称。宏应创建一个名为单元格的 newSheet,并在该工作表中导入相应的 .txt 文件。

我一直在尝试录制宏并更改 VBA 代码,但到目前为止都失败了。

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\UserXP\My Documents\My Dropbox\CIPPEC\1-MIRA\Procesamiento base\OEDE\Tablas\trim\q_employ_pcia_23.txt" _
, Destination:=Range("$A$1")).Name = "q_employ_pcia_23"

有什么想法吗?

谢谢

【问题讨论】:

  • 您的数据在Sheet1 中的外观如何?

标签: import excel vba


【解决方案1】:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\UserXP\My Documents\My Dropbox\CIPPEC\1-MIRA\Procesamiento base\OEDE\Tablas\trim\q_employ_pcia_23.txt" _
, Destination:=Range("$A$1"))
.Name = "q_employ_pcia_23"
.Refresh BackgroundQuery:=False
End With
ActiveSheet.Name = "q_employ_pcia_23"

用于将导入导入新工作表,并且您还想命名新工作表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多