Hi JONvdHeyden and XLD
Thanks for your replies!
Originally Posted by
JONvdHeyden
What do you want to do wth the cell adjacent the match in column G? At the moment all you do is activate the cell. That means looping through each matching cell will simply result in the last match being activated.
I have to edit those cells manually so finding and activating them is the only thing I need to do.
Problem was solved with help from Jerry Beaucaire on the Mr.Excel Forum:
Dim c As String
Dim MySearch As Range
Dim MyFirst As Range
If txtSearch.Value = "" Then Exit Sub
c = txtSearch.Value
If txtSearch.Value <> "" Then
With Sheets("Register")
Set MySearch = .Range("D3:D4190").Find(What:=c, LookIn:=xlValues, SearchDirection:=xlNext)
If Not MySearch Is Nothing Then
Set MyFirst = MySearch
Do
MySearch.Offset(0, 3).Activate
If MsgBox("Found: " & c & ", search for more?", vbYesNo, "Continue?") = vbNo Then
Set MySearch = Nothing
Set MyFirst = Nothing
Exit Sub
Else
Set MySearch = .Range("D3:D4190").FindNext(MySearch)
End If
Loop Until MySearch.Address = MyFirst.Address
MsgBox "Last value found."
Set MySearch = Nothing
Set MyFirst = Nothing
Exit Sub
Else
MsgBox "Found no match for: " & c
End If
End With
End If