BrendanDixon
Board Regular
- Joined
- Mar 7, 2010
- Messages
- 174
- Office Version
- 365
- 2019
- Platform
- Windows
Hi All I am trying to make a search button that when clicked it will find the search term in a specific column and then save the row number in a cell.
I have managed to work this out but it can only find the first instance. I would like it the button can find the next instance of the search term once clicked again. If anyone can please advise how to do this.
Also if it is possible to search a sheet without having to switch to that sheet and then back to the sheet where the result is displayed?
I have managed to work this out but it can only find the first instance. I would like it the button can find the next instance of the search term once clicked again. If anyone can please advise how to do this.
Also if it is possible to search a sheet without having to switch to that sheet and then back to the sheet where the result is displayed?
Code:
Sub Return_Nxt()
Dim Col As String
Dim Src As String
Col = Sheets("Scratchboard").Range("E10").Text
Src = Sheets("Return").Range("C2").Text
Sheets("Database").Select
Columns(Col).Select
On Error GoTo None
Selection.Find(What:=Src, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Sheets("Scratchboard").Range("B13").Value = ActiveCell.Row
Sheets("Return").Select
Exit Sub
None:
Sheets("Return").Select
MsgBox ("Search not found")
End Sub