Solved

Check Excel worksheet tab name for text and hide the sheet

Posted on 2015-02-09
5
71 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 34

Accepted Solution

by:
Norie earned 300 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 200 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 34

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
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 …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

739 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