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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

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
 

Forum statistics

Threads
1,141,227
Messages
5,705,141
Members
421,380
Latest member
Nuwan Sanjeewa Aponso

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
Top