如何把excel每一行各导出为一个txt文本
例如:第一行3个单元格内的内容分别为:a1一第二行3个单元格内的内容分别为:b2二第三行3个单元格内的内容分别为:c3三。。。。。。导出后生成的txt文本为:a.txt(...
例如:第一行3个单元格内的内容分别为:a 1 一第二行3个单元格内的内容分别为:b 2 二第三行3个单元格内的内容分别为:c 3 三。。。。。。导出后生成的txt文本为:a.txt (里面内容为1 一)b.txt (里面内容为2 二)c.txt (里面内容为3 三)。。。。。。请具体说明操作步骤,如需要宏,请给出具体的程序代码,谢谢!
展开
2个回答
展开全部
Sub test()
Dim i, totR As Integer
On Error GoTo Line1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
totR = Range("A65000").End(xlUp).Row
For i = 1 To totR
Rows(i).Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Range("A1") & ".txt", xlUnicodeText
ActiveWorkbook.Close
Next i
Line1: Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Dim i, totR As Integer
On Error GoTo Line1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
totR = Range("A65000").End(xlUp).Row
For i = 1 To totR
Rows(i).Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Range("A1") & ".txt", xlUnicodeText
ActiveWorkbook.Close
Next i
Line1: Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-04
展开全部
同时按Alt和F11进入宏界面,点菜单的插入,模块,粘贴如下代码:
Sub test()
Dim i, totR As Integer
On Error GoTo Line1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
totR = Range("A65000").End(xlUp).Row
For i = 1 To totR
Rows(i).Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Range("A1") & ".txt", xlUnicodeText
ActiveWorkbook.Close
Next i
Line1: Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
在此界面直接按F5运行此宏,完成。
代码未验证,最后先拿简单例子试试。文件应该保存在该Excel文件路径下。
Sub test()
Dim i, totR As Integer
On Error GoTo Line1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
totR = Range("A65000").End(xlUp).Row
For i = 1 To totR
Rows(i).Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Range("A1") & ".txt", xlUnicodeText
ActiveWorkbook.Close
Next i
Line1: Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
在此界面直接按F5运行此宏,完成。
代码未验证,最后先拿简单例子试试。文件应该保存在该Excel文件路径下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询