+ Reply to Thread
Results 1 to 6 of 6

Specific external data from text file

  1. #1
    Forum Contributor Marco-Kun's Avatar
    Join Date
    04-14-2009
    Location
    Holland
    MS-Off Ver
    Dutch:2007
    Posts
    298

    Specific external data from text file

    Hello everyone,

    The code I'm using comes from my last thread: http://www.excelforum.com/excel-prog...-document.html

    I was wondering if it's possible to import specific data from the Test.txt file. The file has the data shown below.
    Is it possible to, on condition, import either the Dutch data, or the English data?

    Kind regards,

    Marco

    Code
    Please Login or Register  to view this content.
    Test.txt
    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Specific external data from text file

    (I assume that you need something other than the days of the week.)

    What I would do is write the whole file into a string (and close the file), then search the string for the data you want.

  3. #3
    Forum Contributor Marco-Kun's Avatar
    Join Date
    04-14-2009
    Location
    Holland
    MS-Off Ver
    Dutch:2007
    Posts
    298

    Re: Specific external data from text file

    You are right, I need something other than the days of the week.
    I'm not really sure how I can achieve this by that method.

    I have a form where someone has to select something in a dropdown list.
    Based on that selection there is another dropdown where data is needed from the text file.
    So for each selection, I need a different part in the text file.

    For example, the first dropdown list has the items: 1, 2, 3, 4 and 5.
    The text file contains:
    Please Login or Register  to view this content.
    If someone picks "2" in the first dropdown, I only want D, E and F, to show in the second dropdown.

    Kind regards and thanks for the help!

    Marco

  4. #4
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Specific external data from text file

    Here is how I would handle the problem. I would put both lists in a string. I would place a marker (such as a comma) between every item in the list; and another marker (such as a semicolon) between the two lists. If your text contains commas and/or semicolons then you have to use some other marker. I also like using vbCr as a marker.


    Please Login or Register  to view this content.
    See: ListBox1.xlsm

  5. #5
    Forum Contributor Marco-Kun's Avatar
    Join Date
    04-14-2009
    Location
    Holland
    MS-Off Ver
    Dutch:2007
    Posts
    298

    Re: Specific external data from text file

    Thank you StevenM, working good.
    I´m trying to combine this with my code for an external file.

    I´m also trying to figure out how to add a third part to the sList.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    How do I add another list?

    Thank you.

    Marco

  6. #6
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Specific external data from text file

    Do you want to add a third list to sList?

    If so, it is the same principle as before. There must be a ";" between each list, and a "," between each element in the list.

    Then after:
    Please Login or Register  to view this content.
    The first list will be sArray(0), the second will be sArray(1), and the third will be sArray(2)
    Because sArray is zero based.

    Then to add the third list to a listbox or combobox, you can:

    Please Login or Register  to view this content.
    The split creates an array. Here it creates an array from the third list.

    The .List from a listbox or combobox can accept a string or variant array.

    P.S.
    Please Login or Register  to view this content.
    Last edited by StevenM; 06-21-2012 at 11:24 AM. Reason: P.S.

+ 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