Hi there,
I am currently working to have a spreadsheet that has a macro that can search for a set cell value in multiple other sheets, then jump to that found cell.#
For example, cell $G$15. A user can enter a six digit code in here, then click a macro button. The macro will search for the instance of this code in a set of 9 other sheets within the same workbook, and then jump the user to that cell.
I have managed before to have this code work when searching within one sheet, but i cannot adapt it properly to search multiple sheets. This is my attempt to adapt, but it does not work.
Any help would be greatly appreciated.
Thanks in advance.
CODE
I am currently working to have a spreadsheet that has a macro that can search for a set cell value in multiple other sheets, then jump to that found cell.#
For example, cell $G$15. A user can enter a six digit code in here, then click a macro button. The macro will search for the instance of this code in a set of 9 other sheets within the same workbook, and then jump the user to that cell.
I have managed before to have this code work when searching within one sheet, but i cannot adapt it properly to search multiple sheets. This is my attempt to adapt, but it does not work.
Any help would be greatly appreciated.
Thanks in advance.
CODE
Code:
Sub Find_First()
Dim FindString As String
Dim Rng As Range
Dim sh As Worksheet
FindString = Sheets("Index").Range("Q12").Value
If Trim(FindString) <> "" Then
For Each sh In ActiveWorkbook.Worksheets
With sh.Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub