Option Explicit
Sub test()
Dim ar$(65432, 2), i&, r&, c%, s$, t, items, f
With Application.FileDialog(1)
With .Filters
.Clear
.Add "文本文件(txt)", "*.txt"
End With
.AllowMultiSelect = True
If .Show Then Set items = .SelectedItems Else Exit Sub
End With
Application.ScreenUpdating = False '自行选择,可多选文本文件
For Each f In items
i = FreeFile
Open f For Input As #i
Do Until EOF(i)
Line Input #i, s
t = Split(s, Space(3))
For c = LBound(t) To UBound(t)
ar(r, c) = t(c)
Next
r = r + 1
Loop
Close #i
Next
Cells.Clear 'Contents
[a1].Resize(1, 3) = Array("AA", "BB", "CC")
[a2].Resize(r, c) = ar
Application.ScreenUpdating = True
End Sub |