Solved

Check Excel worksheet tab name for text and hide the sheet

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

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…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

735 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