Sub WriteToTextFiles()
Dim ws As Worksheet
Dim i As Long
Dim txtFile As Integer
Dim txtPath As String
Set ws = ActiveSheet '设置工作表为当前活动的工作表
txtPath = "d:\" '设置文本文件的保存路径
For i = 1 To 100 '循环遍历100行内容
txtFile = FreeFile '获取一个可用的文件编号
Open txtPath & i & ".txt" For Output As #txtFile '以输出模式打开文本文件
Print #txtFile, ws.Cells(i, 1).Value '将单元格的值写入文本文件
Close #txtFile '关闭文本文件
Next i
End Sub