+ Reply to Thread
Results 1 to 8 of 8

Import a text file by connecting. Select a file by manual.

  1. #1
    Registered User
    Join Date
    02-08-2012
    Location
    Finland
    MS-Off Ver
    Excel 2003 and Excel 2010
    Posts
    12

    Import a text file by connecting. Select a file by manual.

    Hi,

    I try to Import a text file by connecting it. Everything working fine. When I open a Excel file it automatically update the excel sheet's from Txt file. I have 5 different txt file and data goes different excel sheets.
    But now the problem TXT file name is not always be the same. So I need to select manualy the correct file.
    Problem is that I cannot know which txt file I should select, because Excel does not tell it to me. There is some small changes in txt file name, but data have to goes to right sheet.

    Any ideas?

    T
    Last edited by Hakktu; 10-29-2012 at 08:37 AM.

  2. #2
    Registered User
    Join Date
    02-08-2012
    Location
    Finland
    MS-Off Ver
    Excel 2003 and Excel 2010
    Posts
    12

    Re: Import a text file by connecting. Select a file by manual.

    Excel version 2010.

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Import a text file by connecting. Select a file by manual.

    I am guessing you have a macro that does this for you. So step 1 is for you to show us the code. Step 2 would be to tell us how the name changes. You can use things like the LIKE function or a series of Select Case... Case... End Select if you have a list of know possible variants, etc. Without more info we can't really help you.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  4. #4
    Registered User
    Join Date
    02-08-2012
    Location
    Finland
    MS-Off Ver
    Excel 2003 and Excel 2010
    Posts
    12

    Re: Import a text file by connecting. Select a file by manual.

    Hi,
    On the Data tab, in the Get External Data group, click From Text.
    I don't have macro in use at the moment.

    .TXT files can be like this:
    1234567_1212_R.txt
    And next time the same file can be:
    7654321_1547_R.txt
    But this same txt file should be at same excel sheet for every time.

    There is always something similar like "R" in my example.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Import a text file by connecting. Select a file by manual.

    If I understand your question, I have two thoughts on changing the file imported by the Get External data command (both assume that you have remember query definition checked in the data range options)

    1) If you have "prompt for file name on refresh checked," then Excel should prompt you for the filename each time you tell it to update the data range.
    2) If you don't have "prompt for file name on refresh" checked, then you can select the "edit data range" command where you should be given the option to select a new file for the import.

    If I've misunderstood and you are trying to automate this process, you will probably need a macro, and probably the easiest place to start is recording a macro while you use one of the above methods to change the filename, then use the recorded macro as a starting point.

  6. #6
    Registered User
    Join Date
    02-08-2012
    Location
    Finland
    MS-Off Ver
    Excel 2003 and Excel 2010
    Posts
    12

    Re: Import a text file by connecting. Select a file by manual.

    Hi MrShorty,
    Yes you understand it right.
    I have "prompt for file name on refresh" checked, but when excel popup the selection window, there is no info which txt file I need to select.
    Mayby I have to create a macro, it could be easyer than this default process.

    In point 2) you mention "Edit data renge command" where can I select that ? I can't find a correct place to set it up.

    T

  7. #7
    Registered User
    Join Date
    02-08-2012
    Location
    Finland
    MS-Off Ver
    Excel 2003 and Excel 2010
    Posts
    12

    Re: Import a text file by connecting. Select a file by manual.

    Macro created and now my problem is solved.
    Thanks.

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Import a text file by connecting. Select a file by manual.

    Glad you got it all working. If you satisfied with the results then please mark the thread as solved.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

    Thanks.

    abousetta

+ 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