作者:尽做好风水_549_881 | 来源:互联网 | 2023-05-28 18:49
1> Gary's Stude..:
首先更改路径和文件名以符合您的要求,然后将此宏分配给按钮:
Sub TextFileMaker()
Dim MyFilePath As String, MyFileName As String
Dim N As Long, nFirstRow As Long, nLastrow As Long
MyFilePath = "C:\TestFolder\"
MyFileName = "whatever"
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(MyFilePath & MyFileName & ".txt", True)
nLastrow = Cells(Rows.Count, "C").End(xlUp).Row
nFirstRow = 1
For N = nFirstRow To nLastrow
t = Replace(Cells(N, "C").Text, Chr(10), vbCrLf)
a.WriteLine (t)
Next
a.Close
End Sub