Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Check Excel worksheet tab name for text and hide the sheet

Posted on 2015-02-09
5
Medium Priority
?
75 Views
Last Modified: 2015-02-09
I want to check if a workbook contains a tab with the name work* IE: workarea or "work sheet"
and hide the sheets that are so named
0
Comment
Question by:AMixMaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
Norie earned 1200 total points
ID: 40599676
Perhaps.
Dim ws As Worksheet
 
    For Each ws In ActiveWorkbook.Sheets
        If ws.Name LIke "work*" Then
            ws.Visible = False
       End If
   Next ws

Open in new window

0
 
LVL 11

Assisted Solution

by:Wilder1626
Wilder1626 earned 800 total points
ID: 40599687
Hi

You can use:

For Each ws In ActiveWorkbook.Worksheets
        If ws.Name = "workarea" Then ws.Visible = False
        If ws.Name = "work* IE" Then ws.Visible = False
        If ws.Name = "work sheet" Then ws.Visible = False
 Next

Open in new window


If you want to use based on part of a name, you can do something like
For Each ws In ActiveWorkbook.Worksheets
      If Left(ws.Name, 4) = "work" Then ws.Visible = False
Next

Open in new window

0
 

Author Comment

by:AMixMaster
ID: 40599898
fantastic.
except...
it is case sensitive!
and...
if for some reason there are two sheets that have a tab name begining with "work" there is an error..
how to pose this question?
hmm...
0
 
LVL 35

Expert Comment

by:Norie
ID: 40599910
I can't see why having more than one sheet with the name beginning with 'work' would cause an error but what error is it causing?

As for the case thing, try this.
Dim ws As Worksheet
 
    For Each ws In ActiveWorkbook.Sheets
        If LCase(ws.Name) LIke "work*" Then
            ws.Visible = False
       End If
   Next ws

Open in new window

0
 

Author Comment

by:AMixMaster
ID: 40599966
You are correct on both counts!  
I must have mistyped something .  
LCase works fine
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question