如何将dat文件导入到EXCEL,空格转为列
Sub 导数据() With Application.FileDialog(msoFileDialogFilePicker)
.InitialFileName = ThisWorkbook.Path
.Title = "请选择一个或多个文件"
If .Show Then Set fs = .SelectedItems Else Exit Sub
End With
For Each f In fs
Open f For Input As #1
s = s & Input(LOF(1), 1)
Close #1
Next
Set regx = CreateObject("vbscript.regexp")
regx.Pattern = "^\s*\d.+[\r\n]+.*"
regx.Global = True: regx.MultiLine = True
Set mh = regx.Execute(s)
If mh.Count = 0 Then MsgBox "文本格式不符!": Exit Sub
ReDim arr(1 To mh.Count, 1 To 10)
regx.Pattern = "([+-]\s*)?\S+"
For i = 0 To mh.Count - 1
Set mh1 = regx.Execute(Application.Clean(Replace(mh(i), "Skip", "")))
For j = 0 To mh1.Count - 1
arr(i + 1, j + 1) = mh1(j)
Next
Next
这个程序是能够导入dat到EXCEL,但是唯一不足的是:data文件10行导入到EXCEL是5行,源程序看不太懂,有没有大师修改下呢?