Sub 匯入txt()
Dim Arr, Brr, FS$, xLine, xR As Range
t = Timer
ReDim Arr(1 To 6000, 0): Brr = Arr
Application.ScreenUpdating = False
FS = ThisWorkbook.Path & "\sun03.txt"
Open FS For Input As #1
Do While Not EOF(1)
Line Input #1, xLine
xLine = Replace(xLine, " ", " ")
i = i + 1
Arr(i, 0) = xLine
If i > 1 And i Mod 19 = 1 Then Rows(i).PageBreak = xlPageBreakManual
'↑逐一設定分頁線, 速度一定會慢, 可取消這行, 直接將列印的"下邊界"設為13公分
If i Mod 19 = 3 Then Brr(i, 0) = 1
If i Mod 19 = 17 Then Brr(i, 0) = "A"
Loop
Close #1
'--------------------------------
With Range("A1").Resize(i)
.Value = Brr
On Error Resume Next
.SpecialCells(xlCellTypeConstants, 1).RowHeight = 21 '快速選取-常數-數字
.SpecialCells(xlCellTypeConstants, 2).RowHeight = 30 '快速選取-常數-文字
On Error GoTo 0
.Value = Arr
End With
MsgBox Timer - t
End Sub作者: dou10801 時間: 2021-11-6 18:17