Why wont my search work right?

Rick5070

New Member
Joined
Jun 21, 2019
Messages
3
Hello,

I have been working on this database for a while but it has actually grown and now it is not acting like it should.
The search function that I have been using will no longer search the entire database for some reason and I cant seem to figure it out.
Any help would be greatly appreciated.
Here is what I have been using:

VBA Code:
Private Sub CommandButton1_Click() 'Searching Inventory Code

Dim FindString  As String
Dim Rng As Range
Dim MyFind      As Long

FindString = InputBox("Enter Part Number")

    If FindString = vbNullString Then
Exit Sub
    End If

    If Trim(FindString) <> "" Then
With Sheets("Ergo II Spares").Range("A2:J" & Range("J" & Rows.Count).End(xlUp).Row)
Set Rng = .Find(What:=FindString, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)
If Not Rng Is Nothing Then
MyFind = Rng.Row
Do
Set Rng = .FindNext(Rng)

Select Case MsgBox("Found here:" & vbCrLf & Chr(9) & _
"Area " & Chr(9) & ": " & Range("A" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Part " & Chr(9) & ": " & Range("B" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Mikron " & Chr(9) & ": " & Range("C" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Item " & Chr(9) & ": " & Range("D" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Cabinet" & Chr(9) & ": " & Range("E" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Drawer " & Chr(9) & ": " & Range("F" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Manufacturer " & Chr(9) & ": " & Range("G" & Rng.Row).Value & vbCrLf & Chr(9) & _
"Vendor " & Chr(9) & ": " & Range("J" & Rng.Row).Value & vbCrLf & Chr(9) & _
"QTY " & Chr(9) & ": " & Range("H" & Rng.Row).Value & vbCrLf & vbCrLf & _
"Yes = Next" & Chr(9) & "No = Stop", vbInformation + vbYesNo, "Search string: " & FindString)
Case Is <> vbYes: GoTo exitLoop

End Select
Loop While Not Rng Is Nothing And Rng.Row <> MyFind

exitLoop:
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I haven't studied the whole code in detail but here is one likely culprit. Try adding the blue text

Rich (BB code):
With Sheets("Ergo II Spares").Range("A2:J" & Sheets("Ergo II Spares").Range("J" & Rows.Count).End(xlUp).Row)
 
Upvote 0

Forum statistics

Threads
1,215,052
Messages
6,122,878
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top