#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 342
Default Hiding Tabs

This is getting a little complicated for this forum, but give this code a try.
It must be copied to Sheet "Input". The "Yes" and "No" is case sensative.
Changing cell B93 on sheet "Input" will trigger the hiding or unhiding of
sheet "Sheet1".

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B93")) Is Nothing Then
If ThisWorkbook.Worksheets("Input").Range("B93").Valu e = "Yes" Then
ThisWorkbook.Worksheets("Sheet1").Visible = True
Else
ThisWorkbook.Worksheets("Sheet1").Visible = False
End If
End If
End Sub

Let me know if it works.

"jordanpcpre" wrote:

I tried this but it did not work:

Sub HideASheet()
If ThisWorkbook.Worksheets("b93").Range("b93").Value = "Yes" Then
ThisWorkbook.Worksheets("Sheet1").Visible = False
Else
ThisWorkbook.Worksheets("Sheet1").Visible = True
End If
End Sub

I wrote this in the "Input" sheet because that's where the "Yes"/"No" option
is. I need to hide the "Sheet1" sheet if "No" is selected in the "Input"
sheet. Thank you for the help and time.



"TomPl" wrote:


Sub HideA Sheet() --- leave it just as it is.

"ThisWorkbook" would not need to change as long as you copy the code into
the workbook the workbook you are working on.

"Sheet3" is in fact the name of the worksheet you are addressing and needs
to be in quotes.

"False" means that the referenced sheet will be hidden, "True" means the
referenced sheet will be visible.

You could put this in an if statement like this.

Sub HideA Sheet()
If ThisWorkbook.Worksheets("Where the Cell Is").Range("A3").value = "Yes" Then
ThisWorkbook.Worksheets("Sheet3").Visible = False
Else
ThisWorkbook.Worksheets("Sheet3").Visible = True
End If
End Sub

"jordanpcpre" wrote:

Tom, Thanks for the help. In the macro you showed me, what are the
variables? I'm new with macros and need a little help.

Sub HideASheet() ---does any reference go in the ()?

ThisWorkbook ---do I name this the current used tab name or use this name?

"Sheet3" ---I assume this is the worksheet I'm trying to hide

False ---is this a reference to some cell?


Remember, I'm trying to hide a seperate tab base whether or not a specific
cell is labled as "Yes" or "No".

Thank you!



"TomPl" wrote:

Something like this should do the job. You can link it to a worksheet event
or invoke it other ways. I like to create a text box, then assign the macro
to the text box. It is simple and flexible.

Sub HideASheet()

ThisWorkbook.Worksheets("Sheet3").Visible = False

End Sub

"jordanpcpre" wrote:

The validation box is on the same tab as the tab where I'm hiding the rows.
I would like to be able to hide a seperate tab. I can currently hide rows on
a tab that has a validation box. With that same code, can I hide a seperate
tab? Thanks!

"TomPl" wrote:

Where will this "validation box" be if you hide the tab?

"jordanpcpre" wrote:

Below is the code I've been using to hide or show a row based if "yes" or
"no" is selected in a validation box. This has been working. Now I would
like to also hide a Tab if "no" is selected. How can I had a tab in addition
to a row? Thanks!


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Range("171:186").EntireRow.Hidden = (LCase(Range("b92")) = "no")


End Sub



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
Can we modify any of the ribbon tabs or create new ribbon tabs? Scott Sornberger New Users to Excel 2 March 19th 08 11:41 AM
hide tabs from view then lock tabs? slowboat Excel Discussion (Misc queries) 1 December 19th 07 07:06 AM
Can i set up tabs within tabs on Excel? Gizelle Excel Worksheet Functions 5 October 30th 06 12:52 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
Hiding Rows & Tabs at the same time * Kenneth * Excel Discussion (Misc queries) 0 March 29th 06 08:02 PM


All times are GMT +1. The time now is 03:42 PM.

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

About Us

"It's about Microsoft Excel"