Hi guys, I'm new here and just as desperate. I've now looked at quite a few threads etc and can't get my problem solved.
I have a code for: Hide all rows in which there are no values in column D.
Likewise I have a code for: Hide the rows where Peter is in row D. (Peter as an example. I could intigrate here a search field what it looks for).
The Code:
(Sub FindHide()
'Hides all rows with a certain value in column B.
Dim vFind
Dim rSearch As Range
'We ask for a search string. "?" and "*" in the search string
'will work as wildcards/"jokers".
vFind = InputBox("What to search for?")
If Len(vFind) = 0 Then Exit Sub
Application.ScreenUpdating = False
'In this example we search column B only.
'If you want to search the entire worksheet, you write
'e.g. "With ActiveSheet" or "With Worksheets(nb. or name)".
'You can also define another range than column B.
With Columns("D:D")
Set rSearch = .Find(vFind, LookIn:=xlValues)
'If found:
If Not rSearch Then
'Hide the row.
rSearch.EntireRow.Hidden = False
'Now we start a loop that finds all other
'instances. Instances in hidden row are
'not found by the search.
Do
Set rSearch = .FindNext(rSearch)
If Not rSearch Is Nothing Then
'If the search result isn't
'nothing, we hide the row.
rSearch.EntireRow.Hidden = False
Else
'If rSearch was indeed = Nothing, there was
'no instances and we exit the loop.
Exit Do
End If
Loop
End If
End With
BeforeExit:
Set rSearch = Nothing
Application.ScreenUpdating = True
Exit Sub
Resume BeforeExit
End Sub)
However, I can't get it to hide all rows EXCEPT the one with Peter in column D.
Can someone help me with this? I would really appreciate it.
Best regards
Bookmarks