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
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

t_garp

New Member
Joined
Oct 17, 2006
Messages
3
Just a simple Yes or no pull down.

The yes or no decides whether to include that specific sheet
 

agihcam

Well-known Member
Joined
Jan 16, 2006
Messages
1,624
where is the column for the yes or no and the column for the sheet name.
 

agihcam

Well-known Member
Joined
Jan 16, 2006
Messages
1,624
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
 

Watch MrExcel Video

Forum statistics

Threads
1,108,911
Messages
5,525,593
Members
409,652
Latest member
strangelyangely

This Week's Hot Topics

Top