+ Reply to Thread
Results 1 to 16 of 16

.txt to xcel conversion

  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    .txt to xcel conversion

    Hi, Hoping to get some help in figuring out how to import a text file with 10K records in excel. The problem I am having is 1 record in the text file is split in 2 rows and when imported to excel generates the following layout :-
    1 3 4 5 -
    5 7 10

    What I am looking to do is search for "-" which is where the record splits in 2 rows and move the values of row 2 to cells in the first row after "-", while leaving "-" where it is and delete the second row.

    The code would need to loop thru the entire file.

    Thanks
    N

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: .txt to xcel conversion

    Try this little trick that doesnt use VBA.

    Step 1 - use this in a helper colum, copied down...
    =IF(MOD(ROW(),2)=0,A2&A3,"")
    (if your data starts on an odd-numbered row, change the ,1 to ,1)
    step 2 - copy the "answers" and paste values over them
    step 3 - apply filters (Home tab/Editing), filter on blanks, delete those rows, remove filters

    You should now be left with the data in the format you want
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: .txt to xcel conversion

    Here is a VBA solution, albeit not a very elegant one, but it seems to do what you want to have done...
    \
    Please Login or Register  to view this content.
    Be sure to run it on a COPY of your workbook first - not the real thing!!!

    - Moo

  4. #4
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    Hi, Sorry didn't realize the way I had formatted the sample, it didn't display the same way. I have attached a sample this time.
    You will notice the cell values are random and can at time skip cells as well.

    Thanks
    Attached Files Attached Files

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: .txt to xcel conversion

    My suggestion still works, you just need to pic a start cell, then copy it down and across...
    =IF(MOD(ROW(),2)=0,A2&A3,"")

  6. #6
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    Thanks again for your prompt response. I have tried your solution and it seems to be combining the cell values.
    In the updated attachment, below your solution I have also indicated what I am trying to do.

    Thanks
    N
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: .txt to xcel conversion

    Assuming txt file is Tab demilited.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    Thanks Jindon, unless I am not doing something right - It seems like everything is being imported with the entire record in 1 cell.
    Thanks
    N

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: .txt to xcel conversion

    Then I need to see the Txt file, not excel file.

    Just give you an idea how it works.
    txt file is the one converted from your excel file.
    Attached Files Attached Files
    Last edited by jindon; 12-07-2013 at 11:52 AM. Reason: files attached

  10. #10
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    Hi Jindon, I took a deeper dive in the raw data that is being imported and looks like the last character is not always "-" as I originally indicated. So the solution I am looking for now is to take row 2 and merge is to row 1 in the next available cell in row 1. Attached is a sample.

    Thanks
    N
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: .txt to xcel conversion

    Can you upload txt file to be converted?

  12. #12
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    Attached is a sample in text format.

    Thanks
    Attached Files Attached Files

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: .txt to xcel conversion

    And how do you want the result ?

  14. #14
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    After the file is imported in excel, concatenate row 2 to row 1, then row 4 to row 3 and so on.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: .txt to xcel conversion

    Try this one
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-15-2012
    Location
    NY, USA
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: .txt to xcel conversion

    Thanks Jindon, worked perfectly. Thank you!!

+ 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. Greetings Xcel xperts out there
    By Xcelnub in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 05-13-2013, 12:49 PM
  2. Greetings Xcel Gurus!
    By radarzdc in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 11-18-2012, 07:14 AM
  3. [SOLVED] xcel file
    By CJF in forum Excel General
    Replies: 2
    Last Post: 07-18-2005, 11:05 AM
  4. [SOLVED] colums in xcel
    By **- kingdom -** in forum Excel General
    Replies: 2
    Last Post: 05-26-2005, 05:15 PM
  5. [SOLVED] xcel question
    By cokeemp in forum Excel General
    Replies: 2
    Last Post: 01-27-2005, 09:06 PM

Tags for this Thread

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