kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hi ,
I found this code on the web that will hide all rows that contain a specific substring in a cell no matter which column the string is found. It's working great but I want it to look for two substrings at a go. I have the feeling I need to adjust this part , maybe:
So say ABCDEF, as the above is looking for A, I want the one that can look for A and C or D and F etc at the same time
Thanks in advance
Kelly
I found this code on the web that will hide all rows that contain a specific substring in a cell no matter which column the string is found. It's working great but I want it to look for two substrings at a go. I have the feeling I need to adjust this part , maybe:
Code:
Sub Test()
FindAndHide LookingFor:="A"
End Sub
So say ABCDEF, as the above is looking for A, I want the one that can look for A and C or D and F etc at the same time
Code:
Sub FindAndHide(LookingFor As String)
Dim i As Long, j As Long
Dim Rng As Range
Dim Arr As Variant
Dim RowContainsString As Boolean
Set Rng = ActiveSheet.UsedRange
Arr = Rng.Value
LookingFor = LCase(LookingFor)
For i = LBound(Arr, 1) To UBound(Arr, 1)
RowContainsString = False
For j = LBound(Arr, 2) To UBound(Arr, 2)
If InStr(LCase(Arr(i, j)), LookingFor) > 0 Then
RowContainsString = True
Exit For
End If
Next j
If Not RowContainsString Then Rng.Rows(i).Hidden = True
Next i
End Sub
Sub Test()
FindAndHide LookingFor:="A"
End Sub
Thanks in advance
Kelly