So I'm missing something simple but I just can't see it. I'm using .Find to search cells in a range("J6:BFA6") dim'd as "Name" for a user entered word from range("E5") dim'd as "NameS". If the value isn't found, the column becomes hidden, if it's found the column unhides. It hides the columns no problem, issue is it hides them all and won't keep the columns with the searched word unhidden. The cells range "Name" all contain equations, pulling values from cells in another worksheet, but would that matter? Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NameS As Range
Set NameS = Range("E5")
Dim Name As Range
Set Name = Range("J6:BFA6")
Set NameF = Name.Find(What:=NameS, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If Target.Address(0, 0) <> "E5" Then
Exit Sub
ElseIf Target.Address(0, 0) = "" Then
Exit Sub
End If
For Each Cell In Name
If NameF Is Nothing Or Cell.Value = "" Then
Cell.EntireColumn.Hidden = True
Else
Cell.EntireColumn.Hidden = False
End If
Next Cell
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NameS As Range
Set NameS = Range("E5")
Dim Name As Range
Set Name = Range("J6:BFA6")
Set NameF = Name.Find(What:=NameS, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False)
If Target.Address(0, 0) <> "E5" Then
Exit Sub
ElseIf Target.Address(0, 0) = "" Then
Exit Sub
End If
For Each Cell In Name
If NameF Is Nothing Or Cell.Value = "" Then
Cell.EntireColumn.Hidden = True
Else
Cell.EntireColumn.Hidden = False
End If
Next Cell
End Sub