EXCEL中如何读外部读取数据,并导入本身?

来源:百度知道 编辑:UC知道 时间:2024/06/15 07:35:38
要求如题。 外部的文件的数据是用“,”分开的。 例如:
1,2,3,4,5,6,7,8,9
a,b,c,d,e,f,d,h,i,j

如何把这两行数据读取,并存到本身的excel中?(保存也要保存两行)
最好给出代码。如果可行我会加分的。
这个是在excel里做一个按钮 ,所以要在vba里实现。

我来,导入并保存,代码如下:
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\Desktop\excel.txt", Destination:=Range("A1"))
.Name = "excel_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False