有人能看到这个剧本的错误吗?
Option Explicit
Dim lrow As Long
Dim lcol As Long
Dim i As Long
Dim j As Long
Dim strow As Long
Dim fso As Object
Dim xl As Excel.Application
Dim wb As Object
Dim ws As Object
Dim f As Object
Dim Val As Object
Sub arrange_data()
Set fso = CreateObject("Scripting.FileSystemObject")
Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Add
Set ws = wb.Sheets(1)
Set f = fso.OpenTextfile("<path to destination>\gg3-xtra.csv")
i = 1
j = 1
Do Until f.AtEndOfStream
Val = f.ReadLine
If Val = "" Then
i = 1
j = j + 1
Else
ws.Cells(i, j).Value = Val
i = i + 1
End If
Loop
f.Close
wb.SaveAs "output.xls"
End Sub
我希望此脚本执行以下操作
现在的数据集是什么
dataSet1的
...
...
Dataset2
...
...
Dataset3
脚本应该使它看起来像什么
Dataset1 Dataset2 Dataset3
... … …
… … …
… … …
答案 0 :(得分:0)
根据您显示的内容,如果您的csv文件没有空行,则Val
似乎永远不会等于""
。您的csv文件在数据集之间是否有任何空行?