+ Reply to Thread
Results 1 to 7 of 7

split text files stored in some location to multiple files based on a condition

  1. #1
    Registered User
    Join Date
    08-25-2013
    Location
    BANGALORE
    MS-Off Ver
    Excel 2007
    Posts
    4

    Lightbulb split text files stored in some location to multiple files based on a condition

    hi everyone ,

    I am new to EXCEL VBA(macros) , can anyone please inform me about how to split text files stored in some location to multiple files based on a condition(unique data in some position) and file name should be unique data present in the original text file



    thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: split text files stored in some location to multiple files based on a condition

    you can use find function to get the position of your unique value that way you can tell excel where to cut of your parts.
    If solved remember to mark Thread as solved , to mark your thread as Solved select Thread Tools and click Mark thread as Solved.

    I can't read the mind of my wife so then I get picture but no sound .... and then I mostly get the idea, same goes here picture your outcome and I get the idea.

  3. #3
    Registered User
    Join Date
    08-25-2013
    Location
    BANGALORE
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: split text files stored in some location to multiple files based on a condition

    I know the position of the unique value in text file..my requirement is i want to split single text file as multiple text file based on change in the value present in the known position. Any vba or macro which do the above function i want. Please help

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: split text files stored in some location to multiple files based on a condition

    Hello GIRISH_KH,

    Welcome to the Forum!

    It would help to see the text file and to know what the value being looked for is.

    How To Upload Your File
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

    File Manger Picture
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    08-25-2013
    Location
    BANGALORE
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: split text files stored in some location to multiple files based on a condition

    sample.txt

    hi Leith Ross ,

    i have attached the sample file ..I NEED 4 FOUR OUTPUT TXT FILES...RECORDS SHOULD SPLIT AT 8243858,8243861,8243862,8243863


    SAMPLE OF EXPECTED OUTPUT FILES IS SHOWN BELOW

    1ST FILE(FILE NAME SHOULD BE 8243858)
    5825580474,8243858,8/12/2012,00,23/10/2012,1/01/1900
    5830351302,8243858,8/12/2012,00,24/10/2012,1/01/1900
    5830364165,8243858,8/12/2012,00,24/10/2012,1/01/1900

    2ND FILE(FILE NAME SHOULD BE 8243861)
    6097531238,8243861,8/12/2012,00,30/11/2012,1/01/1900
    6061637966,8243861,8/12/2012,00,25/11/2012,1/01/1900

    3RD FILE(FILE NAME SHOULD BE 8243862)
    5962429358,8243862,8/12/2012,00,10/11/2012,1/01/1900
    6091740646,8243862,8/12/2012,00,30/11/2012,1/01/1900

    4TH FILE(FILE NAME SHOULD BE 8243863)
    5887213687,8243863,8/12/2012,00,01/11/2012,1/01/1900


    THANKS IN ADVANCE

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,370

    Re: split text files stored in some location to multiple files based on a condition

    Hi Girish_KH,
    try it (assumes that the Excel file with the macro and the text file "sample-1.txt" are in the same folder)
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-25-2013
    Location
    BANGALORE
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: split text files stored in some location to multiple files based on a condition

    hi nilem ,

    thanks ...i tried it and it works well with the sample data what i have given ...but the same will not work when i put the unique data in some other position .Is it possible to modify the code so as to ask for the position of the unique data and split based on the same.

    i just tried with below data . code has given "path not found " error . please help

    5825580474,8/12/2012,00,23/10/2012,1/01/1900,8243858
    5830351302,8/12/2012,00,24/10/2012,1/01/1900,8243858
    5830364165,8/12/2012,00,24/10/2012,1/01/1900,8243858
    6097531238,8/12/2012,00,30/11/2012,1/01/1900,8243861
    6061637966,8/12/2012,00,25/11/2012,1/01/1900,8243861
    5962429358,8/12/2012,00,10/11/2012,1/01/1900,8243862
    6091740646,8/12/2012,00,30/11/2012,1/01/1900,8243862
    5887213687,8/12/2012,00,01/11/2012,1/01/1900,8243863

+ 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. Split Excel into Multiple csv files based upon the sum of column count.
    By sukanya123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-02-2013, 07:28 PM
  2. Split Excel file into multiple files based on number of rows
    By kingtut86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2013, 03:38 PM
  3. [SOLVED] Split Workbook into Multiple Files based on Worksheet Name + Cell Value
    By CRW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2012, 07:05 AM
  4. Split data from one excel spreadsheet and export to multiple text files
    By jmsavage in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2012, 05:30 AM
  5. Replies: 3
    Last Post: 08-02-2006, 12:35 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