T
todk1
Hello,
I have 200 cells in column D with text in them. I want to use a macro
to generate 200 separate text files containing each individual cell
contents. If possible, I'd like to name of each text file to be based
on the cell adjacent in Column C. Using the macro below, I can generate
a text file from what ever cell I have highlighted. Since I'm not a
good macro writer, I'm not sure how to modify the code so it does what
I need. If someone could help me out I would be so grateful!!!
Sub Export()
Dim r As Range, c As Range
Dim sTemp As String
Open "c:\MyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c
'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Wend
Print #1, sTemp
Next r
Close #1
End Sub
I have 200 cells in column D with text in them. I want to use a macro
to generate 200 separate text files containing each individual cell
contents. If possible, I'd like to name of each text file to be based
on the cell adjacent in Column C. Using the macro below, I can generate
a text file from what ever cell I have highlighted. Since I'm not a
good macro writer, I'm not sure how to modify the code so it does what
I need. If someone could help me out I would be so grateful!!!
Sub Export()
Dim r As Range, c As Range
Dim sTemp As String
Open "c:\MyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c
'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Wend
Print #1, sTemp
Next r
Close #1
End Sub