Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save excel row as a text file

Status
Not open for further replies.

pdybeck

Technical User
Aug 25, 2004
2
US
I have an excel file that contains many rows of information. For each row of information, I would like to save the information in that row out to a separate text and name it by one of the cells in that row. I have 3500 rows in the excel file and would like to end up with 3500 text files named to their corresponding names and populated with data in the row. Does anyone have a method to achieve this?

Pete
 
really quick pass......


Sub sdfs()
Set objFSO = CreateObject("Scripting.FileSystemObject")
For x = 1 To Application.ActiveSheet.UsedRange.Rows.Count
Set objtext = objFSO.createtextfile("c:\temptest" & x & ".txt")
rowstring = ""
For y = 1 To Application.ActiveSheet.UsedRange.Columns.Count
If y = 1 Then
rowstring = Application.ActiveSheet.Cells(x, y)
Else

rowstring = rowstring & vbTab & Application.ActiveSheet.Cells(x, y)
End If

Next y
objtext.writeline rowstring
objtext.Close
rowstring = ""
Next x

End Sub

[yinyang] Tranpkp [pc2]
 
still cnat understand why one would want to do this...but did this help/work?

[yinyang] Tranpkp [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top