Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default 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   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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows Automatically using a Text File List mirdonamy Excel Discussion (Misc queries) 9 January 11th 06 11:11 PM
Links picking up values from an older version of linked file Cate Links and Linking in Excel 4 October 20th 05 01:53 PM
Importing a text file into Excel with too many rows? Nexan Excel Discussion (Misc queries) 2 August 17th 05 01:52 PM
how do I export a worksheet as a fixed format ascii file SVANATTA65 Excel Discussion (Misc queries) 2 June 16th 05 11:49 PM
Insert rows Mr. G. Excel Worksheet Functions 3 March 31st 05 03:49 AM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"