+ Reply to Thread
Results 1 to 7 of 7

Import data from txt

  1. #1
    Registered User
    Join Date
    10-28-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    30

    Import data from txt

    hi,

    I'm trying to import data from txt file which should be separated into cells by "semicolon", "space", "[" and "]".
    The problem is that the options are semicolon, space and just one "other" eparator.
    what should I use in the VB to separate by 2 "other" delimiters "[" and "]"?

    Thanks!

  2. #2
    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: Import data from txt

    Hello michael.g,

    It could be done using VBA. You should include your text file with some before and after examples of the how the data should look on the worksheet.
    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!)

  3. #3
    Registered User
    Join Date
    10-28-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Compicated separation of Imported data

    I'm interested to separate the data imported from ImportedFile.txt by several delimiters:
    1. space
    2. [
    3. ]
    4. ;
    to get the result as in Result.xls.



    I'm using the next code but it enables me to use only 1 "OtherDelimiter"...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by michael.g; 03-22-2010 at 10:31 AM.

  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: Import data from txt

    Hello michael.g,

    The macro below has been added to the attached workbook and can be run by clicking the "Import File" button. Before you run the macro, change the variables FileName and FilePath to where your file is located.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-28-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Import data from txt

    Thanks for the reply, but....

    this solution is not generic as the lenth of the data can be change according to the specific data that loaded and there is much more info in the file besides the values...

    described file attached...

    the important thing is to separate numbers from "[" , "]", ";"
    (the numbers can be also negative)
    Attached Files Attached Files
    Last edited by michael.g; 03-23-2010 at 03:58 AM.

  6. #6
    Registered User
    Join Date
    10-28-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Import data from txt

    required result file attached...


    Thanks
    Attached Files Attached Files

  7. #7
    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: Import data from txt

    Hello michael.g,

    It is good to see the finished result. What I really need is a good sample of raw with which to work. Can you post a more complete text file with actual data?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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