Allowing separate Macro onto same worksheet per cell values?

LeviA

New Member
Joined
Nov 8, 2018
Messages
2
I am very green with Macros. I have a worksheet where a Macro is being used to hide or unhide a separate worksheet based on a dropdown value in a particular cell. My issue is, I need to do this to a 2nd drop down that will hide or unhide a separate worksheet from the previous as well. I am not sure how this should be handled. Below is what I have currently for the first drop down.

Private Sub Worksheet_Change(ByVal Target As Range)If [M19] = "Yes" Then
Sheets("1").Visible = True
Else
Sheets("1").Visible = False
End If
End Sub


This is what I need additionally

Private Sub Worksheet_Change(ByVal Target As Range)If [M20] = "Yes" Then
Sheets("2").Visible = True
Else
Sheets("2").Visible = False
End If
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Code:
[COLOR=#333333]Private Sub Worksheet_Change(ByVal Target As Range)
On error resume next
If [M19] = "Yes" Then[/COLOR]
[COLOR=#333333]Sheets("1").Visible = True[/COLOR]
[COLOR=#333333]Else[/COLOR]
[COLOR=#333333]Sheets("1").Visible = False[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]If [M20] = "Yes" Then[/COLOR]
[COLOR=#333333]Sheets("2").Visible = True[/COLOR]
[COLOR=#333333]Else[/COLOR]
[COLOR=#333333]Sheets("2").Visible = False[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0
Thank you for the help, I appreciate it. Hopefully I can learn the basics before too long and get some of this down.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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