|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 tmplinshi 于 2023-1-13 21:22 编辑
- Sub 导出到文本文件()
- Dim lastCell, rng, line, arr1(), data$
-
- Set lastCell = Cells.Find("*", , xlValues, , xlByRows, xlPrevious)
- Set rng = Range("A2", lastCell)
- For Each line In rng.Rows
- arr1 = Application.Transpose(Application.Transpose(line))
- data = data & Join(arr1, vbTab) & vbCrLf
- Next
- FileWrite data, ThisWorkbook.Path & "\" & [A1] & ".txt"
- MsgBox "导出完毕"
- End Sub
- Sub FileWrite(text, filePath)
- Open filePath For Output As #1
- Print #1, text
- Close #1
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|