ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,235
- Office Version
- 2007
- Platform
- Windows
Morning,
I am using the working code supplied below.
At present some part numbers had started with a zero but now some do & dont use the zero in the part number.
If i type say 12345 nothing is found BUT if i type 012345 i then see the required item.
To save me chaning a lot of part numbers can the code be altered & then check for either.
I am using the working code supplied below.
At present some part numbers had started with a zero but now some do & dont use the zero in the part number.
If i type say 12345 nothing is found BUT if i type 012345 i then see the required item.
To save me chaning a lot of part numbers can the code be altered & then check for either.
VBA Code:
Private Sub CheckIfNumberExists_Click()
Dim ans As String
Dim Fnd As Range
Do Until Not Fnd Is Nothing
ans = InputBox("Enter search for value")
If ans = "" Then Exit Sub
Set Fnd = Range("A:A").Find(ans, , , xlWhole, , , False, , False)
If Fnd Is Nothing Then
If MsgBox("The Part Number " & ans & " Is Not In The List" & vbLf & vbLf & "Do You Want To Search Again ?", vbYesNo + vbCritical, "PART NUMEBR NOT FOUND") = vbNo Then Exit Sub
Else
If MsgBox("The Part Number " & ans & " Can Be Found In Row " & Fnd.Row & vbLf & vbLf & "Search For Another ?", vbYesNo + vbExclamation, "PART NUMBER WAS FOUND") = vbYes Then Set Fnd = Nothing Else Exit Sub
End If
Loop
End Sub