Solved

Check Excel worksheet tab name for text and hide the sheet

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

757 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

22 Experts available now in Live!

Get 1:1 Help Now