+ Reply to Thread
Results 1 to 7 of 7

How do I create a macro to import and sort a txt file with more than one delimiter?

  1. #1
    Registered User
    Join Date
    01-28-2016
    Location
    Stoke, England
    MS-Off Ver
    2016
    Posts
    24

    How do I create a macro to import and sort a txt file with more than one delimiter?

    Hey everyone,
    I’d like some help to create a marco that will import a txt file containing up to 100 lines into excel and sort it into columns. I’m ashamed to say that I’ve been doing it manually as I’ve never had the time to learn how to use excel properly until now.
    I’m a slow learner but I’m determined to learn how use excel as it could really help me at work.
    Thanks for any help

    this is the format of the txt source file:

    "Jonnyenglish___________X"
    Optimized meds: 9 units: (34.0006% sin) 22.3611: Meda, Medabc, demB#2, Meda, Medabc, demab
    "JonnyBrovo___________X"
    Optimized meds: 5 units: (60.106% sin) 5: Meda, Medabc, dema, Meda, Medabc, demab
    "JonnyDepp___________X"
    Optimized meds: 9 units: (17.6% sin) 90.11: Meda, Medabc, htctttt, Meda, Medabc, demab
    "JonnyKnoxville_________X"
    Optimized meds: 7 units: (34.0006% sin) 31.3322: Dpata#3, Medabc, dema, Meda, Medabc, demab

    This is how I would like it to be sorted:
    Jonnyenglish___________X 9 units 34.0006% sin 22.3611 Meda, Medabc, demB#2, Meda, Medabc, demab
    JonnyBrovo_____________X 5 units 60.106% sin 5 Meda, Medabc, dema, Meda, Medabc, demab
    JonnyDepp______________X 9 units 17.6% sin 90.11 Meda, Medabc, htctttt, Meda, Medabc, demab
    JonnyKnoxville_________X 7 units 34.0006% sin 31.3322 Dpata#3,Medabc,dema,Meda,Medabc,demab

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: How do I create a macro to import and sort a txt file with more than one delimiter?

    IS your desired result 5 columns of data? Perhaps you could post an example text file, and the workbook that you would want created from that example file
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    01-28-2016
    Location
    Stoke, England
    MS-Off Ver
    2016
    Posts
    24

    Re: How do I create a macro to import and sort a txt file with more than one delimiter?

    Hi, thanks for your reply. As requested - I’ve attached a couple of files as examples.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: How do I create a macro to import and sort a txt file with more than one delimiter?

    Try this macro:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-28-2016
    Location
    Stoke, England
    MS-Off Ver
    2016
    Posts
    24

    Re: How do I create a macro to import and sort a txt file with more than one delimiter?

    Thankyou! It works like a charm. I’d like to learn how you did that - could you recommend some reading material?? Again, thank you.

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,937

    Re: How do I create a macro to import and sort a txt file with more than one delimiter?

    Write complex data-analysis macros for 30 years or so...

    I figured out the steps needed then recorded a macro doing them. Then I edited the code and made it flexible.

    I always recommend a book by John Walkenbach in his "Power Programming with VBA in Excel xxxx" It is really comprehensive and clear.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How do I create a macro to import and sort a txt file with more than one delimiter?

    As it appears you've reached a conclusion, I've marked this thread SOLVED for you.
    FYI, this is done through the Thread Tools located above the first post in this thread. Thanks.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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. [SOLVED] Import text file and sort the data
    By amar05 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2016, 01:58 PM
  2. [SOLVED] import text file using multiple spaces as delimiter
    By Kaden265 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2014, 11:50 AM
  3. Replies: 6
    Last Post: 08-30-2013, 01:59 AM
  4. Implementing TextFile import Delimiter settings on TXT Import VBA Script
    By Canuckle777 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-19-2013, 02:06 PM
  5. Replies: 4
    Last Post: 05-02-2013, 11:16 AM
  6. VBA macro for Inserting text file(having pipe as delimiter) into Excel sheet
    By Nusrat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2013, 05:40 AM
  7. [SOLVED] How to import multiple txt file and arrange by column with delimiter
    By warlock89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2012, 12:50 AM

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