+ Reply to Thread
Results 1 to 13 of 13

Export Individual Rows To Individual Text Files?

  1. #1
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Export Individual Rows To Individual Text Files?

    Hi Chaps ,

    I Have A Large Excel Sheet ( Over 10,000 Rows ) , I Need To Export Every Row Which Has Two Colums ARTIST & TITLE , To There Own Individual Text File.

    I also need The File To Be Named With The Exported Artist And Title With A - To Seperate Them

    So

    Title Artist

    Wonderful Life Black


    can be exported to a .txt file and named :

    Wonderful Life - Black

    No Data Needs To Be Stored In The Actual File , Just A Name.

    Hope You Can Help :-)

    Jimmer

  2. #2
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Export Individual Rows To Individual Text Files?

    may be this test and give us feedback.
    and must change sheet name which you have data
    and must change the path where you wanted save your files.
    Please Login or Register  to view this content.
    Give Feedback and Click(*)

  3. #3
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    Hi Thanks For That , Just Tried It Today , I Have Input the data Like this


    Sub myTest()
    Dim myObj As Object, tFile
    Dim wsht As Worksheet
    Dim myPath As String
    Dim lr As Long
    Dim i As Integer
    myPath = "C:\Users\Jay\Documents\myTest" ' change the Path as you need
    Set wsht = Worksheets("Book1") ' change the sheet name as you have
    lr = wsht.Cells(Rows.Count, 1).End(xlUp).Row
    Set myObj = CreateObject("Scripting.FileSystemObject")
    For i = 1 To lr
    Set tFile = myObj.CreateTextFile(myPath & Cells(i, 1) & "-" & Cells(i, 2) & ".txt", True)
    tFile.WriteLine Cells(i, 1) & "-" & Cells(i, 2)
    tFile.Close
    Next i
    End Sub



    I get A Runtime Error 9 ( Subscript Out Of Range)
    Last edited by jimmer18; 01-13-2014 at 09:32 AM. Reason: Re-write

  4. #4
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Export Individual Rows To Individual Text Files?

    try this below code

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    Ok Cool ,thanks venka , getting close now, I Played With The Worksheet Name ( After Realising I Was Trying To Pull Info From Wrong Place).

    Sub myTest()
    Dim myObj As Object, tFile
    Dim wsht As Worksheet
    Dim myPath As String
    Dim lr As Long
    Dim i As Integer
    myPath = "C:\Users\Jay\Documents\myTest\" ' change the Path as you need
    Set wsht = Worksheets("Sheet1") ' change the sheet name as you have
    lr = wsht.Cells(Rows.Count, 1).End(xlUp).Row
    Set myObj = CreateObject("Scripting.FileSystemObject")
    For i = 1 To lr
    Set tFile = myObj.CreateTextFile(myPath & Cells(i, 1) & "-" & Cells(i, 2) & ".txt", True)
    tFile.WriteLine Cells(i, 1) & "-" & Cells(i, 2)
    tFile.Close
    Next i
    End Sub



    Text Files Are Produced In The Right Format Etc , But Only The First 43 Rows Are Exported and i get a "path not found error 76"

  6. #6
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Export Individual Rows To Individual Text Files?

    please use the code tags #
    if its not working for you please attach a sample workbook. i will put the code in it and make sure everything is right.

  7. #7
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    Sorry , I Can't Seem To Work This Out , Heres A Sample Workbook.sample book.xlsx

  8. #8
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: Export Individual Rows To Individual Text Files?

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    03-28-2013
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    226

    Re: Export Individual Rows To Individual Text Files?

    ok I have tested you code, you have 60 files names but i am getting 44 files. its because you have some duplicate names.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    Hi Slx ,

    That Works But strangely also only outputting a maximum of 43 rows ( txt files)

  11. #11
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    But In The Main Excel File There Are Over 10,000 Rows , And More Than 43 Unique Artists and titles...

  12. #12
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    Full Listings.

    if anybody fancys a play . .. Hopefully

    myTest.xlsx

  13. #13
    Registered User
    Join Date
    01-12-2014
    Location
    bristol , uk
    MS-Off Ver
    Excel 2008
    Posts
    8

    Re: Export Individual Rows To Individual Text Files?

    ok found the problem ,

    doesn't like certain chars in the text fields such as / # etc.

    so will break the operation when it encounters these. duplicates are removed but only exact copies in both fields.

    I'm going to consider This Solved , It Will Take A Little Sorting Out , But Thanks For The Starting Point!!!


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export rows as individual files
    By fogster74 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2017, 11:32 PM
  2. [SOLVED] Exporting filled rows into individual text files
    By mockingjay3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2013, 05:34 AM
  3. Outputting individual cells to individual text files
    By db9429 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2013, 03:39 PM
  4. Export Individual Rows as PDF
    By mvollmer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-10-2012, 05:00 PM
  5. reducing files: multiple rows per individual
    By zoltan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-24-2011, 05:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1