請測試看看,謝謝
Sub test()
Dim Arr, a, FN, T$, T1$, R&, C&, s&
FN = "D:\test.txt"
Open FN For Output As #1
Arr = Sheets(1).[a1].CurrentRegion
For R = 1 To UBound(Arr)
If R = 1 Then a = Array(12, 80, 8, 7, 16, 18, 3) Else a = Array(80, 7, 40, 16, 18, 12, 40, 5, 20, 8, 18, 40)
For C = 2 To UBound(Arr, 2)
T = Arr(R, C - 1): T1 = Arr(R, C): If T = "" Then GoTo 99
Ept = a(s) - Len(T)
If Ept > 0 Then For j = 1 To Ept: Arr(R, 1) = Arr(R, 1) & " ": Next
Arr(R, 1) = Arr(R, 1) & T1
s = s + 1
99: Next C
s = 0: Print #1, Arr(R, 1)
Next R
Close #1
End Sub作者: kkooo15 時間: 2022-3-23 17:50