+ Reply to Thread
Results 1 to 11 of 11

VBA to Open Group of Workbooks Based on Name and Filepath

  1. #1
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Cool VBA to Open Group of Workbooks Based on Name and Filepath

    What I want to do is create a Macro that opens a group of workbooks from a list of names and filepaths in columns A and B. I want column A to have the names of the files, and column B to have the filepath/location of where the files are stored. The macro would then go through and open all files.

    Any suggestions on what code would work?

    Thank you for the help, I really appreciate it!

    Thanks,


    J
    Last edited by Jason Carlos; 05-20-2014 at 02:40 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    Hi Jason

    It'll be something like this
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    The code works great, every file opens but after I get an error stating:

    "Run-time error '1004':

    'C:\' could not be found. check the spelling of the file name, and verify that the file location is correct.

    If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved or deleted."

    Just to reiterate, this is after every file opens.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    Hi Jason

    Do you have anything else in Columns A or B other than the File Names and Paths?

  5. #5
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    I have headers that say "Name" and "Filepath." I also have a concatenate formula that combines the files name I post in column C with ".xlsx" so if finds the formula. I uploaded an example of the worksheet. I also changed the code too:

    Please Login or Register  to view this content.
    This way it pulls from the ws named "filepath"
    Attached Files Attached Files

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    Hi Jason

    How does Column C get populated?

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    Hi Jason

    Assuming you're populating Column C I'd suggest modifying the Code. Column A is filled with Formulas so we can't use Column A.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    That is where I manually enter in the file name. The way I do that is by clicking on the file in a folder pressing F2 and the copy/pasting into excel. Because this doesn't paste the extension .xlsx in there, that is why I have the concatenate formula in column A

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    Hi Jason

    Is the extension always .xlsx?

    If so, use this Code
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-09-2014
    Location
    Phoenix Arizona
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    You are the man!

    Solved!

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA to Open Group of Workbooks Based on Name and Filepath

    You're welcome...glad I could help. Thanks for the Rep.

+ 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] Macro to select and open filepath stored at worksheet
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-01-2014, 04:32 AM
  2. [SOLVED] Trying to get the filepath on "Open", but get filepath of a temporary file instead
    By ianpwilliams in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-22-2013, 12:27 AM
  3. [SOLVED] Copying files from a selected filepath to a filepath mentioned in a worksheet's cell
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 03:59 PM
  4. Replies: 3
    Last Post: 09-24-2010, 04:04 AM
  5. Replies: 4
    Last Post: 07-19-2010, 09:05 AM

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