+ Reply to Thread
Results 1 to 8 of 8

Activate Sheet using Partial Sheet name

  1. #1
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Activate Sheet using Partial Sheet name

    Hello!

    I have searched and searched for a previous response to this question to no avail.

    I am writing a VBA program in Excel 2010 (Windows) that is going to iterate through several workbook, copy data, and paste said data into another workbook.

    The issue is that each of the workbooks I am copying data from do not have the exact same sheet names.

    For example, Workbook A has a sheet named "Mean_xxx_xxxx", Workbook B has a sheet named "xxx_mean_xxxx", and Workbook "C" has a sheet named "xxx_xxxxxxxx_Mean". I want to copy data from each of those workbooks and paste it into workbook "D".

    As can be seen, each workbook's sheet that I want has the string "Mean" in it.

    Is it possible to activate wach workbook's sheet using only the partial string of each sheet?

    Any help would be greatly appreciated!

    Sample Code:

    Please Login or Register  to view this content.
    Instead of writing the specific sheet name, as in the code above, can I seach for the partial string "mean" inside the full sheet names?


    Thanks,

    Grazian2

    Excel 2010

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Activate Sheet using Partial Sheet name

    Yes, you can loop the sheets and use like "*mean*" etc
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

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

    Re: Activate Sheet using Partial Sheet name

    Short answer, no you can't activate a sheet with the partial name.

    What you could do is loop through the worksheets in a workbook to find the one you want using a partial match.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Activate Sheet using Partial Sheet name

    Thank you for the responses!

    @Nathansav: What would that look like?

    Please Login or Register  to view this content.
    Is that what you mean?

  5. #5
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Activate Sheet using Partial Sheet name

    @Norie:

    Would I use the Find function to seach for the string inside of the sheet name, or did you have a more effective idea?

  6. #6
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Activate Sheet using Partial Sheet name

    hrazian2, here's an example (untested):
    Please Login or Register  to view this content.
    Cheers, berlan

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

    Re: Activate Sheet using Partial Sheet name

    This code will find the first sheet with 'mean' in it's name in all 3 workbooks.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-19-2013
    Location
    Chicago, United States of America
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Activate Sheet using Partial Sheet name

    Thank you for the help, those both worked great!

+ 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. Code to Activate a sheet 1 [IF] Userform box is "X" if not Activate Sheet 2
    By Invicta084 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-07-2014, 08:50 AM
  2. Replies: 1
    Last Post: 05-29-2013, 01:20 PM
  3. [SOLVED] Worksheet Activate when user selects sheet NOT when sheet is created from a template sheet
    By y0rk1e72 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-26-2012, 02:47 PM
  4. Prevent code in "Sheet Activate" from running when sheet made visible from other macr
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-21-2006, 04:15 AM
  5. Return to Current Sheet in On (sheet activate) event macro
    By Paul Moles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2005, 11:06 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