Hello again.
I need the ability to search in current active sheet S/n which i enter in a textbox sitting in the top of the current activesheet.
data sheet called "S2".
all S/N located at A6:A50000
User using the sheet will input S\N in the TextBox ("txtsearch") and will click a command button to search.
result should be: vba code will find the S/n
1. if there is a match , will prompt "match found" with msg box
2. after click Ok on msg box , vba code will give focus on the found cell.
if nothing found: simple msg box with : "no s/n found".
so far i got this but im lost with debbuger saying things like " out of range" , "overflow" everytime im trying .
hope you guys can help me again.
Code
Option Explicit
Private Sub FindButton_Click()
Dim ws As Worksheet
Dim FindString As String
Dim Rng As Range
Set ws = ThisWorkbook.Worksheets("S2")
FindString = txtsearch.Value
If Trim(FindString) <> "" Then
Set Rng = ws.Cells.Find( _
What:=FindString, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End If
End Sub
Display More