Dim fso As Object, filledCellsCount As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Set target = fso.CreateTextFile("d:\javainput.txt", True)
filledCellsCount = 8
For i = 1 To filledCellsCount - 1
target.WriteLine Cells(i, 1)
Next
target.Write Cells(filledCellsCount, 1)
target.Close
Set fso = Nothing
Sub TEST()
Dim fso, T$, target
Set fso = CreateObject("Scripting.FileSystemObject")
Set target = fso.CreateTextFile("d:\javainput.txt", True)
For i = 1 To [A65536].End(3).Row: T = T & vbCrLf & Cells(i, 1): Next
target.Write Mid(T, 3)
target.Close
Set fso = Nothing
End Sub https://learn.microsoft.com/zh-t ... eatetextfile-method