Solved

Check Excel worksheet tab name for text and hide the sheet

Posted on 2015-02-09
5
67 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
  • 2
  • 2
5 Comments
 
LVL 33

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 33

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now