On Error Resume Next
fengefu = " * " '分隔符自己定义
Dim fso As Object
Dim MyTxt As Object
Dim MyFName As String
Set fso = CreateObject("Scripting.FileSystemObject")
With ActiveSheet
MyFName = "c:\1.txt" '路径及文件名还有尾缀都可以自行修改
Set MyTxt = fso.CreateTextFile(Filename:=MyFName, OverWrite:=True) '=TRUE是直接覆盖,False是提示
For i = 1 To 100'最大行数可自行修改
MyTxt.write .Cells(i, 2) & fengefu & .Cells(i, 3) & fengefu & .Cells(i, 4) & fengefu & .Cells(i, 5) & Chr(10)'chr(10)是换行符
Next
MyTxt.Close
End With
Set MyTxt = Nothing
Set fso = Nothing
MsgBox "路径为:" & MyFName, vbInformation, "提示"
更多问题请关注:iphive