I have a code that searches one page for a value entered into a inputbox. Everything is working great if the result is found; if it is not found or is left blank it turns all my shapes on the page one color (which is part of the code at the bottom). I would like to simply exit the sub if there is no any entries or if the entry is not found
below is my code:
below is my code:
Code:
Sub Bevel25_Click()
'SEARCH CODE
Dim myITEM As String, myRng As Range, NewLoc As String
Dim Found As Range, wrksht As Worksheet
Set wrksht = Sheets("List")
'Search for Product Code or Lot Number
myITEM = InputBox("Enter what you would like to search for.", "Search", "Enter Here")
Exit Sub
wrksht.Select
Set Found = Columns("C:D").Find(What:=myITEM, LookIn:=xlValues, lookat:=xlWhole)
If Found Is Nothing Then
MsgBox "Not found"
Else
Range("F" & Found.Row).Select
NewLoc = ActiveCell.Value
End If
Sheets("Rack Chart").Select
ActiveSheet.Shapes(NewLoc).Select
'Turn Selection YELLOW
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 0)
.Transparency = 0
.Solid
End With
MsgBox ("The location of your item is " & NewLoc)
'Turn Selection back to BROWN
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(153, 102, 51)
.Transparency = 0
.Solid
End With
Sheets("Rack Chart").Range("a1").Select
End Sub