+ Reply to Thread
Results 1 to 3 of 3

Import worksheets based on partial sheet name

  1. #1
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    845

    Import worksheets based on partial sheet name

    Hi there,

    I have a template workbook into which I need to import sheets from different excel files.
    All files are in the same folder/location as the template.
    The macro below works fine if the full name of the sheet is known.

    The problem I have is, the sheet name sometimes is not exactly 'Start', but it could be 'Start SEP 22', 'Start October 2022', etc.
    The sheet name always starts with 'Start'.
    Ideally it would be as simple as looking for 'Start*', but I was not able to make wildcards work when looking for sheet names.
    Was also thinking about Left(sh.name,"Start",5) or something like that, but can't get it working.

    Any help, pointers for the code with copying any sheet starting with 'Start' would be much appreciated.

    Thanks


    Please Login or Register  to view this content.
    If your Question is answered; please mark it SOLVED. If you are happy with a member's solution, say 'Thanks' and click the 'Star' to Add Reputation.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Import worksheets based on partial sheet name

    Perhaps you could use something like this.

    It will loop through the sheets of each workbook being opened and if one is found with a name starting with 'Start' it will copy it.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    845

    Re: Import worksheets based on partial sheet name

    Thanks a lot Norie,

    Super fast reply and it works perfectly!

+ 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. VBA to Import Worksheets Based on File Names in List
    By Gitty in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2019, 05:25 PM
  2. Replies: 1
    Last Post: 02-17-2016, 05:57 AM
  3. Import Macro to import separate files to separate worksheets - deletes existing worksheets
    By Hondahawkrider in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2015, 02:24 PM
  4. Replies: 2
    Last Post: 10-31-2013, 05:00 PM
  5. Replies: 3
    Last Post: 07-10-2013, 01:39 PM
  6. Copying row based on partial cell match and paste into existing worksheets
    By colinh69 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2011, 02:42 PM

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