当前位置: 动力学知识库 > 问答 > 编程问答 >

excel - Importing text data in VBA

问题描述:

I am writing some VBA to import a big group of files into Excel. The code below works fine

 With ActiveSheet.QueryTables.Add(Connection:= _

"TEXT;P:\Application Data\Desktop\Delta_FinancialStatementsRestate_0C00009DBX_2013-10-31.dat" _

, Destination:=Range("A2"))

.Name = "Delta_FinancialStatementsRestate_0C00009DBX_2013-10-31_7"

.FieldNames = True

...etc

But when I try and replace the file path with an Array I have defined which has filepaths saved it doesn't work

With ActiveSheet.QueryTables.Add(Connection:=MyFiles(l), Destination:=Range("A2"))

.Name = "Delta_FinancialStatementsRestate_0C00009DBX_2013-10-31"

.FieldNames = True

Can someone please advise on how to get this working. The array definitely has the right value in it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: