您的位置:首页 > 其它

Excel单元格中的数据输出到.txt

2013-01-09 00:07 253 查看
以第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

这里有更详细的讲解:http://www.excelpx.com/blog-11303-5308.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐