+ Reply to Thread
Results 1 to 13 of 13

Organize large space delimited text file into appropriate rows and columns in excel.

  1. #1
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Organize large space delimited text file into appropriate rows and columns in excel.

    I have collected data into a large text file such that each value is space delimited. I would like to import this text file into Excel in order to analyze it better. I have pasted a portion of the text file into Excel in order to attach it to this ticket. Whether I copy and paste the data or import it, I don't care, just as long as I can organize it in Excel.

    I need the data to be organized into 5 different columns with the first value going into A1, the second value into B1, and continuing until the fifth value is in E1. Once there, it needs to repeat so that the sixth value is placed in A2, the seventh in B2 until the the tenth value is in E2.

    For example, if I had this series of data:
    0053 02A3 0000 0000 0000 0054 02A3 0000 0000 0000 0055 02A3 0000 0000 0000

    It would need to be organized like this, with each value in it's respective row and column:
    0053 02A3 0000 0000 0000
    0054 02A3 0000 0000 0000
    0055 02A3 0000 0000 0000

    I hope that makes sense, let me know if you need any clarification.
    Thanks!
    Attached Files Attached Files

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

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Your explanation of the need is fine. If you provide a sample of your TEXT file, that would be better.
    _________________
    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!)

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

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    This seems to be pretty fast with the file created from the text in your sample file.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    I've attached the .txt file, although I had to reduce its size so that the uploader would accept it.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Thanks for the help!
    I am running into a few errors while trying to implement the code you gave me. Forgive me since I do not have much experience using macros.
    When I'm in the macro editor and I try to run the script you gave me, I get this error:
    "Run-time error '1004'
    Application-defined or object-defined error"

    I also tried assigning this macro to a button to see if I would get the same error. The error I received when I tried to press the buttons was:
    "Microsoft Visual Basic
    400"

    I've looked up these errors online and am trying to make sense of them, if you have any input I would certainly appreciate it. I've also attached a portion of the text file for testing.

    Thanks!

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

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Macro seemed to work without error on your sample text file, too.

    Here's the macro installed into a basic workbook. Compare this to what you did to see what is different.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Thanks.
    The workbook you gave me fails (with the same error) at the same point where mine does, when this line is called:
    fNAME = Application.GetOpenFilename("Text Files (.txt),.txt")

    I am using Excel 2011, if that helps at all.

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

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Is that a MAC version? I'm not that well-versed in MAC requirements.

  9. #9
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    It is a MAC version, should I expect the functions to be that different...?

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

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Yes, MAC OS is very different from Windows.

    Quote Originally Posted by rdlaner View Post
    Thanks.
    The workbook you gave me fails (with the same error) at the same point where mine does, when this line is called:
    fNAME = Application.GetOpenFilename("Text Files (.txt),.txt")

    I am using Excel 2011, if that helps at all.
    Some Googling suggests something like this might work:

    Please Login or Register  to view this content.

    I have no way to test that or debug it for you. That "path to documents folder" may be an editable string.

  11. #11
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    Thanks, I'll try out a few things and let you know what I find.

  12. #12
    Registered User
    Join Date
    08-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    7

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    I ended up just removing the arguments for the GetOpenFilename function and everything appears to be working now.

    Thanks for your patience and help!

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

    Re: Organize large space delimited text file into appropriate rows and columns in excel.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Space delimited text to multiple columns
    By mogdog1981 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-09-2010, 08:55 AM
  2. Import space delimited text file into excel
    By vijay2482 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2009, 12:29 PM
  3. Opening a space delimited text file in Excel
    By c_mei83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2009, 02:00 AM
  4. Replies: 3
    Last Post: 06-18-2005, 01:05 AM
  5. [SOLVED] Excel 2003 Importing large delimited text file
    By Ron in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2005, 11:06 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