|
Sub 数组法()
Dim s$(), arr$(), a, sh As Worksheet
Dim f$, i&, j%, m&, k&, n%, r&
f = ThisWorkbook.Path & "\test2.txt"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Name <> ActiveSheet.Name Then sh.Delete
Next
Application.DisplayAlerts = True
Cells.ClearContents
Open f For Input As #1
s = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbCrLf)
Close #1
r = Rows.Count
For k = 0 To UBound(s) Step r
ReDim arr(1 To r, 2)
n = n + 1
If n > 1 Then Sheets.Add After:=Sheets(Sheets.Count)
m = 0
For i = k To k + r - 1
If i = UBound(s) Then Exit For
m = m + 1
a = Split(s(i), vbTab)
For j = 0 To 2
arr(m, j) = a(j)
Next
Next
Range("a1").Resize(m, 3) = arr
Next
Application.ScreenUpdating = True
End Sub
|
|