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
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.