按alt+f11进vba,右键在thisworkbook上插入模块,贴入以下代码
Option Explicit
Sub 整行写入()
Dim i As Integer, c As Integer
Dim str As String
c = ActiveCell.Row
For i = 1 To Range("IV" & c).End(1).Column
str = str & Cells(c, i).Value & IIf(i = Range("IV" & c).End(1).Column, "", ",")
Next i
'MsgBox str
Dim fs, fi As Object, fn As String
fn = ThisWorkbook.Path & "\" & c & ".txt" '如果要改成固定的文件名,可以改成比如fn="c:\test.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set fi = fs.createtextfile(fn, True)
fi.write str
fi.Close
End Sub
然后在你的宏下为这个宏指定一个快捷键,按下后,它会将一行的内容写入你的xls所在目录的行数.txt里。
具体导出到什么地方?