我一直在努力解决这个问题。我在XLS文件中有以下数据块,基本上ColA是随机的,每个字段大约有300多个字符。我需要将ColA放入文本文件中,ColB和ColC作为文本文件名。
ColA ColB ColC
BLA,432$#@.<>H|3525 John Smith
BLA,rewq$#@.<>H|3525 John Smeeth
BLA4rew,rerr>H|3525 John Smamth
在文件John_Smith.txt中输出带有ColA数据的John_Smith.txt,依此类推每行。
答案 0 :(得分:0)
试试这个,
Sub test()
Dim filename As String
Dim filecontents As String
Dim writerng As Range
Dim cell As Range
Set writerng = Sheets("Sheet1").Range("A1:A10")
For Each cell In writerng
filename = cell.Offset(, 1).Value & "_" & cell.Offset(, 2) & ".txt"
Open filename For Output As #1
filecontents = cell.Value
Print #1, filecontents
Close #1
Next cell
End Sub