你A列有没有重复的??? 我的意思是说 , 有没有一个文本要写入 多条数据的情况
导入 到当前目录 对应A列 命名 txt:
Sub ctxt()
Dim f As String
i = 2
Do While Cells(i, 1) <> ""
If Cells(i, 1) <> Cells(i - 1, 1) Then
f = ThisWorkbook.Path & "\" & Cells(i, 1) & ".txt"
Open f For Output As #1
For t = i To i + Application.WorksheetFunction.CountIf(Range("A:A"), Cells(i, 1)) - 1
Print #1, Cells(i, 2)
i = i + 1
Next
Else
i = i + 1
End If
Close #1
Loop
End Sub
Public Sub A1作为TXT文本的标题B1作为TXT文本的内容()
intF = FreeFile
文本的标题 = Cells(1, 1) '也就是A1,我认为叫"文件名"更合理,请保证其合法性
文本的内容 = Cells(1, 2) '也就是B1
Open "c:\" & 文本的标题 For Output As #intF
Print #intF, 文本的内容
Close intF
End Sub
什么鬼???????
是导出的问题吗?