Hello,
Very much a VBA novice here. I have some code below that has been very helpful in hiding/unhiding sheets based on input in a cell. However, I'm looking for a way to combine the two criteria so that the sheet will be unhidden if *both* M26=YES and if M9<>0. If either of those conditions are *NOT* met, I'd like for the sheet to be hidden. I've been doing a lot searching around and experimenting but I haven't been able to get anywhere. Any advice on how I can modify the code below to make the visibility of the sheet dependent on both conditions?
Very much a VBA novice here. I have some code below that has been very helpful in hiding/unhiding sheets based on input in a cell. However, I'm looking for a way to combine the two criteria so that the sheet will be unhidden if *both* M26=YES and if M9<>0. If either of those conditions are *NOT* met, I'd like for the sheet to be hidden. I've been doing a lot searching around and experimenting but I haven't been able to get anywhere. Any advice on how I can modify the code below to make the visibility of the sheet dependent on both conditions?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Whoa
Application.EnableEvents = False
If Not Intersect(Target, Range("M26")) Is Nothing Then _
Sheet15.Visible = (UCase(Trim(Range("M26").Value2)) = "YES")
If Not Intersect(Target, Range("M9")) Is Nothing Then _
Sheet15.Visible = (Len(Trim(Range("M9").Value2)) <> 0)
Letscontinue:
Application.EnableEvents = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume Letscontinue
End Sub