+ Reply to Thread
Results 1 to 5 of 5

Macro to open multiple files with changing names

  1. #1
    Registered User
    Join Date
    05-27-2013
    Location
    Buellton, California
    MS-Off Ver
    Excel 2007
    Posts
    26

    Macro to open multiple files with changing names

    Hello,
    I am trying to make a macro to open a series of .csv files and copy data into the active workbook. The names of the files are different each time, with a common suffix.
    An example file name would be "SPW2292-11-(A-B-C)-G_I13_C1_002-w-vFine-X-Top" where "SPW2292-11-(A-B-C)-G_I13_" will change each time.

    Is there a way to open files with just the last section of the name?

    Here is what I have now that will open the first file:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to open multiple files with changing names

    Try something like this (not tested).

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-27-2013
    Location
    Buellton, California
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to open multiple files with changing names

    Thanks, that seems much easier to follow, but I am still getting an error (Run-time error 1004) that says the file cannot be found.
    The files are in separate folders than the excel file that the macro is in, so it looks like I need to add a way for the wbSource to find the SourceFile in the correct folder?

    How would I add that in the Loop?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to open multiple files with changing names

    Sorry I missed that. Try this...

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-27-2013
    Location
    Buellton, California
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Macro to open multiple files with changing names

    Quote Originally Posted by AlphaFrog View Post
    Sorry I missed that. Try this...
    Don't worry, I accidentally left that out.
    Thanks a lot for the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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