+ Reply to Thread
Results 1 to 3 of 3

Macro to open workbooks of multiple specific names...

  1. #1
    Registered User
    Join Date
    02-17-2014
    Location
    manchester
    MS-Off Ver
    Excel 2003
    Posts
    6

    Macro to open workbooks of multiple specific names...

    Morning,


    I currently have a piece of code that opens all of the files in a folder that are called "*agent*", opens them and copies information. Now, these files come with numbers at the beginning which, are always the same. I only want to open certain files that begin with, for example, 801, 802, 803, 804, 805 and 806. How would I write this into my code? As you can see from the below code, it now looks for the files that all have "agent" in the name, but this is opening files that have that name but are not the right ones.

    Here is my current macro...

    Please Login or Register  to view this content.

    Many thanks in advance

    Edit: I hope this isnt as simple as putting "MyFile = Dir(MyFolder & "\*801*", "\*802*")" etc, lol
    Last edited by hairypocketman; 05-02-2014 at 06:04 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Macro to open workbooks of multiple specific names...

    if instr(1,myFile.Name,"803")<>0 or instr(1,myFile.Name,"804")<>0 then

    YOUR CODE

    end if
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    02-17-2014
    Location
    manchester
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro to open workbooks of multiple specific names...

    AWESOME!!!!

    Thanks nathansav


+ 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. [SOLVED] Open Multiple Workbooks, Record names, Copy paste to Active Workbook, Close the Workbooks
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 06:09 AM
  2. [SOLVED] Run Macro on Multiple OPEN Workbooks
    By DrEcosse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2012, 09:22 PM
  3. Macro to extract data from multiple workbooks, specific sheet, specific cells
    By crissandraauree in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 03:54 PM
  4. Multiple open workbooks pulling their names!?
    By The Phil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-28-2010, 01:44 PM
  5. macro to open multiple workbooks at once
    By easty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2010, 08:48 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