Sub Test1128()
Dim Arr, R&, C&
myPath$ = ThisWorkbook.Path & "\"
xlsPath$ = myPath & "A001.xlsx" 'xls檔案來源路徑,請自行設定(預設本程式檔案路徑下)
txtPath$ = myPath & "A001.txt" '輸出txt的路徑&檔名,請自行設定(預設本程式檔案路徑下)
With Workbooks.Open(xlsPath, , True).Sheets(1)
Arr = .[A1].CurrentRegion
For R = 1 To UBound(Arr)
For C = 2 To UBound(Arr, 2)
Arr(R, 1) = Arr(R, 1) & Arr(R, C)
Next C
Arr(R, 1) = Arr(R, 1) & String(20, " ")
Next R
.[A1].Resize(UBound(Arr), UBound(Arr, 2)) = Arr
.Columns("B").Resize(, UBound(Arr, 2)).Delete
.SaveAs txtPath, 42
.Parent.Close True
End With
End Sub作者: n7822123 時間: 2020-11-28 19:03