Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Macro to hide worksheet based upon text in the name

Is it possible to have a macro that hides worksheets based upon text
contained or not contained in the worksheet name? Suppose i have several
worksheets but want to hide ony the ones that don't have the text "HOLD" in
the name;

worksheet names:
Data_HOLD
Data Selection_HOLD
etc....
or maybe base it upon the WS tab color....

Thanks,
Joe M.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro to hide worksheet based upon text in the name

Hi,

This will hide all worksheets with Hold anywhere in the name

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If InStr(1, ws.Name, "Hold", vbTextCompare) Then
ws.Visible = False
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Is it possible to have a macro that hides worksheets based upon text
contained or not contained in the worksheet name? Suppose i have several
worksheets but want to hide ony the ones that don't have the text "HOLD" in
the name;

worksheet names:
Data_HOLD
Data Selection_HOLD
etc....
or maybe base it upon the WS tab color....

Thanks,
Joe M.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Macro to hide worksheet based upon text in the name

Thanks. But I have discovered that I will have to rename some other sheets
for this to work and it will affect some macros. What about by the WS tab
color? Tis will be easier for me. Sorry for not being sure earlier.

Thx,
Joe M.

"Mike H" wrote:

Hi,

This will hide all worksheets with Hold anywhere in the name

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If InStr(1, ws.Name, "Hold", vbTextCompare) Then
ws.Visible = False
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Is it possible to have a macro that hides worksheets based upon text
contained or not contained in the worksheet name? Suppose i have several
worksheets but want to hide ony the ones that don't have the text "HOLD" in
the name;

worksheet names:
Data_HOLD
Data Selection_HOLD
etc....
or maybe base it upon the WS tab color....

Thanks,
Joe M.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro to hide worksheet based upon text in the name

Hi,

This will hide sheets with red tabs

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Tab.Color = 255 Then
ws.Visible = False
End If
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Thanks. But I have discovered that I will have to rename some other sheets
for this to work and it will affect some macros. What about by the WS tab
color? Tis will be easier for me. Sorry for not being sure earlier.

Thx,
Joe M.

"Mike H" wrote:

Hi,

This will hide all worksheets with Hold anywhere in the name

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If InStr(1, ws.Name, "Hold", vbTextCompare) Then
ws.Visible = False
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Is it possible to have a macro that hides worksheets based upon text
contained or not contained in the worksheet name? Suppose i have several
worksheets but want to hide ony the ones that don't have the text "HOLD" in
the name;

worksheet names:
Data_HOLD
Data Selection_HOLD
etc....
or maybe base it upon the WS tab color....

Thanks,
Joe M.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Macro to hide worksheet based upon text in the name

I tried with several WS with red tabs but it only hides one. I double checked
to make sure red was selected. What is wrong?

Thanks,

Joe M.




"Mike H" wrote:

Hi,

This will hide sheets with red tabs

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Tab.Color = 255 Then
ws.Visible = False
End If
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Thanks. But I have discovered that I will have to rename some other sheets
for this to work and it will affect some macros. What about by the WS tab
color? Tis will be easier for me. Sorry for not being sure earlier.

Thx,
Joe M.

"Mike H" wrote:

Hi,

This will hide all worksheets with Hold anywhere in the name

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If InStr(1, ws.Name, "Hold", vbTextCompare) Then
ws.Visible = False
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Is it possible to have a macro that hides worksheets based upon text
contained or not contained in the worksheet name? Suppose i have several
worksheets but want to hide ony the ones that don't have the text "HOLD" in
the name;

worksheet names:
Data_HOLD
Data Selection_HOLD
etc....
or maybe base it upon the WS tab color....

Thanks,
Joe M.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default Macro to hide worksheet based upon text in the name

I just tested Mikes code successfully. Are they the same color and in the
same workbook?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Joe M." wrote in message
...
I tried with several WS with red tabs but it only hides one. I double
checked
to make sure red was selected. What is wrong?

Thanks,

Joe M.




"Mike H" wrote:

Hi,

This will hide sheets with red tabs

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Tab.Color = 255 Then
ws.Visible = False
End If
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Joe M." wrote:

Thanks. But I have discovered that I will have to rename some other
sheets
for this to work and it will affect some macros. What about by the WS
tab
color? Tis will be easier for me. Sorry for not being sure earlier.

Thx,
Joe M.

"Mike H" wrote:

Hi,

This will hide all worksheets with Hold anywhere in the name

Sub Hide_shts()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If InStr(1, ws.Name, "Hold", vbTextCompare) Then
ws.Visible = False
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis
that
introduces the fewest assumptions while still sufficiently answering
the
question.


"Joe M." wrote:

Is it possible to have a macro that hides worksheets based upon
text
contained or not contained in the worksheet name? Suppose i have
several
worksheets but want to hide ony the ones that don't have the text
"HOLD" in
the name;

worksheet names:
Data_HOLD
Data Selection_HOLD
etc....
or maybe base it upon the WS tab color....

Thanks,
Joe M.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to hide sheets based upon cell value Joe M. Excel Discussion (Misc queries) 3 January 13th 10 07:05 PM
Macro to copy a worksheet and rename based upon text entered in 1 edeaston Excel Discussion (Misc queries) 5 December 5th 08 05:47 PM
Macro to Hide rows based on value of column F Scott Marcus Excel Discussion (Misc queries) 10 October 27th 06 11:57 PM
Macro to hide and unhide based on criteria [email protected] Excel Discussion (Misc queries) 1 June 5th 06 08:05 PM
Formula or Macro to hide a row based on a cell value JP Excel Discussion (Misc queries) 0 February 3rd 06 06:10 PM


All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"