Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Export Rows individuall to a new file?
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!!! |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Deleting Rows Automatically using a Text File List | Excel Discussion (Misc queries) | |||
Links picking up values from an older version of linked file | Links and Linking in Excel | |||
Importing a text file into Excel with too many rows? | Excel Discussion (Misc queries) | |||
how do I export a worksheet as a fixed format ascii file | Excel Discussion (Misc queries) | |||
Insert rows | Excel Worksheet Functions |