+ Reply to Thread
Results 1 to 15 of 15

Hide tab based on tab name

  1. #1
    Registered User
    Join Date
    03-14-2020
    Location
    York
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    15

    Hide tab based on tab name

    Hi,
    I already have a macro to change tab names automatically based on call values, any tabs that are ‘spare’ and not needed are ***** spare1 , spare2, spare3 and so on. I am looking for a macro to hide tabs which include ‘spare’ in there name if that’s possible if someone can help please?

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Hide tab based on tab name

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-14-2020
    Location
    York
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    15

    Re: Hide tab based on tab name

    Hi, thanks for the quick reply! This works great, however it doesn't reshow tabs when the data is changed in the cell that dictates the tabs name, also is it possible to add it to my current button I've created so it runs after the code before it so that i dont have to add to buttons if that makes sense? I've just to make it work but have so far failed!
    The code before is:

    Please Login or Register  to view this content.
    Also
    Last edited by AliGW; 11-18-2020 at 10:26 AM.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,968

    Re: Hide tab based on tab name

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are still quite new, I will do it for you today.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: Hide tab based on tab name

    How about
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-14-2020
    Location
    York
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    15

    Re: Hide tab based on tab name

    Hi, Thanks for your reply. The code still works for changing the tab names based on value, but it doesn't seem to work for hiding any tabs with 'spare' in the name and vice versa it doesn't unhide the ones that don't. Any suggestions?

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: Hide tab based on tab name

    Did you change the code at all?

  8. #8
    Registered User
    Join Date
    03-14-2020
    Location
    York
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    15

    Re: Hide tab based on tab name

    Hi, No i didnt change the code, Just copy and pasted it in. Ive just retried copying the code in and i am now getting a run time error 1004. method 'name' of object '_worksheet' failed

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: Hide tab based on tab name

    Can you please supply a workbook, that shows that behaviour.

  10. #10
    Registered User
    Join Date
    03-14-2020
    Location
    York
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    15

    Re: Hide tab based on tab name

    Ive attached a sample. On the Store tab, the wheel is the button you click to update the tab names. These are based on the list of names to the right of this which autofilf automatically into H2 of each sheet.
    I want this set up to stay but the spare tabs i would like to hide and then once a new member joins the team i put their name into the store tab column, press the update button and the sheet then appears again. This is the sheet iam working on
    Thanks for looking at this for me
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: Hide tab based on tab name

    The code I supplied isn't even in your workbook.
    The reason you got the RTE is that neither the Staff nor Store sheets have anything in H2, so try
    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Hide tab based on tab name

    This is worksheet event code with H1 in Sheet1 as reference cell.

    Please Login or Register  to view this content.
    To paste the code
    Right click on Sheet tab --> view code
    VB window opens.
    Paste the code
    Close the window.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  13. #13
    Registered User
    Join Date
    03-14-2020
    Location
    York
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    15

    Re: Hide tab based on tab name

    Thanks for all your help Fluff13! It works now, thanks for ironing out the kinks! Sorry about the code missing from upload sheet i had to upload a very basic sheet that i quickly put together as i cant upload my actual sheet due to GDPR etc...

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,081

    Re: Hide tab based on tab name

    Glad to help & thanks for the feedback.

  15. #15
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Hide tab based on tab name

    @ashaw2

    Have you seen post#12

+ 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] Automatically Hide or not Hide columns, based on cell value (to the left)
    By sherylt13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2018, 07:47 PM
  2. [SOLVED] Hide row based on value
    By Challebjoern in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-17-2017, 03:07 AM
  3. Hide Rows/Hide Columns Based on Value in Cell
    By brickwall823 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2015, 02:42 PM
  4. [SOLVED] Hide Columns based on level of access e.g. if "Read Only" Hide G:G
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-16-2013, 06:10 AM
  5. [SOLVED] Hide rows based on variables that are based on formulas
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2012, 06:21 AM
  6. VBA hide row based on pull down with button to toggle show/hide
    By myronr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 06:07 PM
  7. Hide a row based on a cel value
    By guillaume in forum Excel General
    Replies: 5
    Last Post: 05-18-2006, 08:15 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