Hello Experts, I am trying to hide a name range whenever a cell has a particular value. So far, the following code doesn't throw out any errors but the name range is not hidden when the B6 range equals "Terminated". Here's the code I have:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("Table5[#All]").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange _
:=Range("B2:C3"), Unique:=False
Dim xlName As Name
Dim NametoHide As String
NametoHide = "TERMINATION_DATE"
If ThisWorkbook.Worksheets("Dashboard").Range("B6").Value <> "Terminated" Then
For Each xlName In ThisWorkbook.Names
If xlName.Name = NametoHide Then
xlName.Visible = False
End If
Next xlName
End If
End Sub