Excel工具(批量生成txt)
Sub txt()
Dim i, j, arr(), brr(), myRow, myCol
arr = Sheet1.UsedRange
myRow = UBound(arr, 1)
myCol =UBound(arr, 2)
For i = 1 To myRow
Open ThisWorkbook.Path & "\" & arr(i, 1) & ".txt" For Output As #1
Print #1, Range("B" & CStr(i)). Value
Close #1
Next
End Sub
使用说明:
-
Excel表格,第一列作为每个TXT的文件名,第二列是TXT的内容
-
在Excel中按下Alt+F11,选择对应的表,复制上面的代码,点击运行
-
生成的TXT在Excel对应的目录中