+ Reply to Thread
Results 1 to 4 of 4

VBA to Import Worksheets Based on File Names in List

  1. #1
    Registered User
    Join Date
    08-08-2019
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    4

    VBA to Import Worksheets Based on File Names in List

    Hi-
    I have the following code to import a worksheet into my workbook.

    Please Login or Register  to view this content.
    Basically, the folder path and file extension are constant, but the actual file name is drawn from cell E2.

    I now have a list of file names I want to import. The list always starts in the same cell (A6), but the last row varies based on the list length.
    I'm not sure how to change the code above so that the vba loops through all the names listed.

    On top of that, I don't want any errors if the file doesn't exist, but rather, the text "Unable to Locate File" should populate in column B of the corresponding row (e.g. if the file listed in A6 doesn't exist, the value of cell B6 should now be "Unable to Locate File")

    Appreciate any and all help!
    Last edited by Gitty; 08-08-2019 at 03:23 PM.

  2. #2
    Registered User
    Join Date
    03-01-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: VBA to Import Worksheets Based on File Names in List

    @Gitty, do you have file names which are starting from cell A6 in the workbook where code is written and on which sheet you have the list?
    share the sample file

  3. #3
    Registered User
    Join Date
    08-08-2019
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    4

    Re: VBA to Import Worksheets Based on File Names in List

    The code is in a different workbook, but the worksheet where the file names are is the ActiveSheet.
    I use index numbers for my sheet, so the ActiveSheet is Worksheets(2), and the list starts Worksheets(2).Range("A6").

  4. #4
    Registered User
    Join Date
    08-08-2019
    Location
    USA
    MS-Off Ver
    Office365
    Posts
    4

    Re: VBA to Import Worksheets Based on File Names in List

    I now have the following code, but it looks like I can't use .Text for a Range that is larger than one cell...

    Please Login or Register  to view this content.

+ 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. Import Multiple Worksheets into Master File
    By Dan_B in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2015, 03:09 PM
  2. [SOLVED] VBA code to import data from multiple worksheets in the same file
    By WHATSXL in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2014, 11:24 AM
  3. VBA to import csv file scattered over different worksheets
    By endoskeleton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2011, 11:48 AM
  4. Import Worksheets from Another File
    By cratediggah in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2006, 08:43 AM
  5. Import file list
    By Josh Craig in forum Excel General
    Replies: 2
    Last Post: 07-13-2006, 01:45 AM
  6. No answer yet... Data Import from Many Worksheets to on file...
    By M Imran Buhary in forum Excel General
    Replies: 2
    Last Post: 06-13-2006, 03:35 AM
  7. Amalgamate Several Worksheets into one file thru Data import
    By M Imran Buhary in forum Excel General
    Replies: 0
    Last Post: 05-28-2006, 06:35 AM

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