Results 1 to 5 of 5

Thread: Query from folder - different worksheet Names

  1. #1
    Seeker Will_Texas's Avatar
    Join Date
    Dec 2021
    Location
    Houston, Texas
    Posts
    15
    Articles
    0
    Excel Version
    365

    Query from folder - different worksheet Names



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hello, I have a query from a Folder that has three excel files. The query works, but only if all the .xls files have the same worksheet name.
    I will likely have many files over time in the Folder & don't want to have to change it every time.

    Does anyone know how I can change the query function to get around this worksheet reference?

  2. #2
    Super Moderator Bob Phillips's Avatar
    Join Date
    Mar 2011
    Posts
    1,938
    Articles
    0
    Excel Version
    O365
    As long as the structure of the sheets is constant, you should be able to import them by sheet index. Explained here Import first sheet of an Excel workbook into Power Query, regardless of its name

  3. #3
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    2,118
    Articles
    0
    Excel Version
    365
    Could you post the M-code?

  4. #4
    Seeker Will_Texas's Avatar
    Join Date
    Dec 2021
    Location
    Houston, Texas
    Posts
    15
    Articles
    0
    Excel Version
    365
    Yes, but after that first file import is done, of the first worksheet, it seems to append the Source to worksheets of that name, and if other files worksheet names are different than that, then it creates an error for (only) those files.

    I've attached a screenshot of (at least my issue).
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Different Worksheet Names.jpg 
Views:	12 
Size:	97.2 KB 
ID:	10809  

  5. #5
    Super Moderator Bob Phillips's Avatar
    Join Date
    Mar 2011
    Posts
    1,938
    Articles
    0
    Excel Version
    O365
    Are you saying that happened AFTER you had made the change to import by index number?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •