+ Reply to Thread
Results 1 to 5 of 5

how to link userform / ComboBox value to import text file

  1. #1
    Registered User
    Join Date
    01-01-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2013
    Posts
    26

    how to link userform / ComboBox value to import text file

    Hello Everyone. I am novice and seek your assistance to make more effective macro.

    There are about 80 text files in a folder. Those text files are named P01.txt, P02.txt and so on. Below I have a macro to import data from P39.txt

    However I am looking for more efficient macro to avoid changing file path when I have to import any other file between P01.txt to P99.txt

    I thought one solution would be linking with userform's value. For example on the file I have attached, there is ComboBox which contains value P01 to P99. Is it possible to select value and import txt file? suppose if I select P05 on ComboBox and run the macro - would it be possible to get P05.txt imported on Destination? Hope I have been able to clarify the scenario, but not sure it may work as I wish. Any better suggestion is most welcome.


    Any help would be appreciated.

    Many thanks and regards




    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by yogi_himalayan; 01-02-2014 at 05:36 AM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: how to link userform / ComboBox value to import text file

    Hi Yogi and welcome to the Forum.

    The following routines may help you with your problem. One selects a FOLDER and the other selects a FILE. The 'Picker' routines that do the hard work are courtesy of Microsoft.

    Lewis

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-01-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: how to link userform / ComboBox value to import text file

    Hi Lewis,

    Many thanks for your time and consideration, but my sincere apologies, as I am novice and spent 6 hours trying to utilize codes below but could not succeed. I believe, in future I would be able to comprehend better and apply it again.

    However I have simplified output requirement and attached revised macro.


    Now I would like to put vlaue of Sheets("Control").Range("C2") and Sheets("Control").Range("C3") as path to replace Direct Path - "TEXT;C:\Users\Dell\Documents\Macro files\VBA workshop\P39.txt", Destination:=Sheets("VAR").Range("$A$1"))

    Codes are below but I am getting error and I believe there is something wrong with syntax. Your assistance is very much appreciated.

    Kind Regards

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: how to link userform / ComboBox value to import text file

    Hi again,

    QueryTables are beyond my field of expertise, but in the sample file, it looked like you had a problem with the naming of the locations of the cells that point to the file.

    Lewis

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-01-2014
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: how to link userform / ComboBox value to import text file

    Hi Lewis,

    After playing around for a while got the right code as below that works.

    correct code to link QueryTables with cell is - "TEXT;" + xPath + yTxt,

    Please Login or Register  to view this content.
    Last edited by yogi_himalayan; 01-03-2014 at 10:55 PM.

+ 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. Link Text box to a column of combobox
    By 555Rage in forum Excel General
    Replies: 0
    Last Post: 09-21-2012, 03:22 AM
  2. [SOLVED] Import text file from VBA code; import all numbers as text
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-19-2012, 05:19 PM
  3. Link text Box to Combobox in Userform and autoupdate database
    By abhiD in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-20-2012, 06:58 AM
  4. Populate a userform combobox from a .txt file
    By ashmott in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-20-2011, 02:24 AM
  5. userform combobox list link to sheets of different name
    By brainfreez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-27-2008, 03:36 PM

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