View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Export Rows individuall to a new file?

Does this just mean one column?

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet
Dim FNum As Long
Dim FName As String

Set wks = Worksheets("sheet1")

With wks
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

FNum = FreeFile

For Each myCell In myRng.Cells
Close FNum
FName = "C:\temp\" & Format(myCell.Row, "000") & "_Output.txt"
Open FName For Output As FNum
Print #FNum, myCell.Text
Close FNum
Next myCell

End Sub

Or multiple columns????????

Option Explicit
Sub testme2()

Dim myRow As Range
Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet
Dim FNum As Long
Dim FName As String
Dim myStr As String

Set wks = Worksheets("sheet1")

With wks
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))

FNum = FreeFile

For Each myRow In myRng.Rows
myStr = ""
For Each myCell In .Range(.Cells(myRow.Row, "A"), _
.Cells(myRow.Row, .Columns.Count).End(xlToLeft)).Cells
myStr = myStr & " " & myCell.Value
Next myCell
If myStr < "" Then
myStr = Mid(myStr, 2)
End If

Close FNum
FName = "C:\temp\" & Format(myRow.Row, "000") & "_Output.txt"
Open FName For Output As FNum
Print #FNum, myStr
Close FNum
Next myRow
End With
End Sub


wrote:

Hello all, I have an excel sheet that has lets say 10 rows that look
like this:

1 My information, etc, etc..
2 My information, etc, etc..
3 My information, etc, etc..

and so on.

Is there a macro or script or anything I can use that would take each
INDIVIDUAL row and export it to a new text file? So for a document
that had 10 rows it would make 10 text files with whatever information
was in it.

Thank you!!!


--

Dave Peterson