+ Reply to Thread
Results 1 to 7 of 7

Using a Macro to search several predetermined locations to return "yes/no"

  1. #1
    Registered User
    Join Date
    12-24-2012
    Location
    Ark
    MS-Off Ver
    Excel 2010
    Posts
    3

    Using a Macro to search several predetermined locations to return "yes/no"

    I am trying to write a macro that will search an excel table that has pre-determined locations that need to be searched. For example, when the macro is run I would like it to loop thru the locations and search for any file extensions with *.xls. (later on I may need to add several extensions to search for as well). If that location has a file with that extension I would like it to return a "Yes" back in the table. Here is a dummy table that closely resembles what I'm looking at. I am looking at a table that would look through 200 locations on 5 different drives


    Bank Name File Location .xls file?
    Bank A H:\BankA\file (return yes or no)
    Bank B P:\BankB\file (return yes or no)

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    re: Using a Macro to search several predetermined locations to return "yes/no"

    Cross-posted here http://www.mrexcel.com/forum/excel-q...rn-yes-no.html

    If you must X-Post...Why you should post a link
    The Forum Rules
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    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: Using a Macro to search several predetermined locations to return "yes/no"

    Hello mpricha,

    Welcome to the Forum!

    This macro expects row 1 to hold the column headers. The macro reads the file extensions in row 1 starting with column "C". The extensions should include the asterisk, for example: *.xls. You can new extensions as needed without changing the macro code. The macro determines the number of rows with file paths automatically. If a file path does not exist then the message "Path not found" will appear under the extension columns. Copy this code and paste it into a new VBA module in your workbook.
    Please Login or Register  to view this content.
    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!)

  4. #4
    Registered User
    Join Date
    12-24-2012
    Location
    Ark
    MS-Off Ver
    Excel 2010
    Posts
    3

    re: Using a Macro to search several predetermined locations to return "yes/no"

    awesome! this worked, question... how do i add the capabilty to add extensions. Maybe I am searching 4 or 5 extensions at a time in these folders. Are all extensions in cell C1? *.xls, *.doc?? Thanks for the help!

  5. #5
    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: Using a Macro to search several predetermined locations to return "yes/no"

    Hello mpricha,

    Each new extension will go into a separate column. For eaxample: C1 = *.xls, D1= *.doc, etc.

  6. #6
    Registered User
    Join Date
    12-24-2012
    Location
    Ark
    MS-Off Ver
    Excel 2010
    Posts
    3

    re: Using a Macro to search several predetermined locations to return "yes/no"

    Leith thanks so much, this is going to save so much time at work!

  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: Using a Macro to search several predetermined locations to return "yes/no"

    Hello mpricha,

    'S e do bheatha.
    (You're Welcome.)

    Bliadhna mhath ùr!
    (Happy New Year!)

+ 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