Closed Thread
Results 1 to 6 of 6

Excel VBA code for selecting a folder then search & open specified files in that folder

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    17

    Excel VBA code for selecting a folder then search & open specified files in that folder

    Hi There,

    I'm looking for the VBA code that firsts prompts the user to select a folder where the files are stored and then searches for a specified file. The full filename does not always remain, so i need to search with a part name something like Processed-File will be present in the filename.

    I'm able to pick the folder where the files are located but not able to automatically select the file that i'm looking for

    This is the code i have got so far which isn't working;

    Please Login or Register  to view this content.
    Appreciate any help in completing this task

    Cheers
    Last edited by JBeaucaire; 06-19-2013 at 12:56 AM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  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: Excel VBA code for selecting a folder then search & open specified files in that folde

    THis should get you to the next part:

    Please Login or Register  to view this content.
    _________________
    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
    Registered User
    Join Date
    09-21-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Excel VBA code for selecting a folder then search & open specified files in that folde

    Thanks, It worked wondefully!

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

    Re: Excel VBA code for selecting a folder then search & open specified files in that folde

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

  5. #5
    Registered User
    Join Date
    08-25-2021
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    2

    Re: Excel VBA code for selecting a folder then search & open specified files in that folde

    Hello, I copy this VBA code and only add "Sub b()" on the first line code, and "End Sub" in the last line code. I run the macro and it shows me error
    Attachment 745601Attachment 745600

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,482

    Re: Excel VBA code for selecting a folder then search & open specified files in that folde

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed 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