如何把excel工作簿的数据按照对应的要求批量转为txt文档 50
Sub test()
Dim fso As Object
Dim myTxt As Object
Dim MyFName As String
Dim i As Long, j As Long
Set fso = CreateObject("Scripting.FileSystemObject")
For i = 2 To [A1].End(xlDown).Row
If Cells(i, 1) <> Cells(i - 1, 1) Then
MyFName = ThisWorkbook.Path & "/" & Cells(i, 5) & ".txt"
Set myTxt = fso.CreateTextFile(Filename:=MyFName, OverWrite:=True)
For j = 1 To 5
myTxt.write Cells(1, j) & vbTab
Next
myTxt.write vbCrLf
End If
For j = 1 To 5
myTxt.write Cells(i, j) & vbTab
Next
myTxt.write vbCrLf
Next
myTxt.Close
Set myTxt = Nothing
Set fso = Nothing
End Sub
有没有不用代码的,或是简单一点的呀,因为表格的数据 比列举的要多很多
批量转为txt肯定需要代码的,不用代码你只能复制粘贴了