Thread: Search and Goto
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JW[_2_] JW[_2_] is offline
external usenet poster
 
Posts: 638
Default Search and Goto

On Sep 27, 7:14 pm, Dgwood90
wrote:
I need to create a formular or macro that when a number is typed, it will
take you to the cell. I know about the find feature, but if there is a way to
search and goto, that would be preferable.


OK is clicked, it will locate the first occurrence of that value in
the active worksheet.
Sub findMe()
Dim nput As String, found As Range
nput = InputBox("Enter what to find")
If nput < "" Then
Set found = Cells.Find(What:=nput, After:=Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not found Is Nothing Then
Range(found.Address).Activate
Else
MsgBox nput & " not found"
End If
End If
End Sub