How to hide a worksheet tab by selecting from pulldown list

t_garp

New Member
Joined
Oct 17, 2006
Messages
3
Hi,

I am tryinh to figuree out how to write a macro that will hide a given worksheet that is not in use.

Scenario: Financial model for electricity generation for multiple locations. Main control sheet allows to select via pulldown menu if that given location should be included in combined financial results. (I got that covered). However, I would like that the worksheet for that location as it is not in use to be hidden automatically.

Thanks for your thoughts
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Just a simple Yes or no pull down.

The yes or no decides whether to include that specific sheet
 
Upvote 0
right click the sheet in question > view code > then paste this code;
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 2 Then Exit Sub
If Target.Value = "" Then Exit Sub
    If UCase(Target.Value) = "YES" Then
    Sheets(Target.Offset(, -1).Value).Visible = True
        Else
            Sheets(Target.Offset(, -1).Value).Visible = False
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top