以第3列单元格中的数据为名称,建立.txt 文件,并写入第6列中的数据。从第2行循环至205行。
共创建204个.txt文件。代码如下:
Sub importData()
Dim sFile As Object
Dim FSO As Object
Dim iRow As Integer
Set FSO = CreateObject("Scripting.FileSystemObject")
'loop process:
For iRow = 2 To 205
Set sFile = FSO.CreateTextFile("Your path/" & Sheet1.Cells(iRow, 3).Value & ".txt", True)
sFile.writeline (Sheet1.Cells(iRow, 6).Value)
Next iRow
sFile.Close
Set sFile = Nothing
Set FSO = Nothing
End Sub