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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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