View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
anderssweden anderssweden is offline
external usenet poster
 
Posts: 8
Default search function without error if not found

I have a search function that I intend to use for several variables. I wonder
how you write the search function so that you do not get error if search is
unsuccessful but rather an informative message box or likewise. My code so
far is:
Private Sub findQC()
Dim rng As Range
Dim findVal As String
Dim i As Integer
Set rng = Worksheets("Dimension").Cells.Find("qc", LookIn:=xlValues)
i = 0
Do Until IsEmpty(rng.Offset(i + 1, 0)) = True
i = i + 1
Loop
End Sub

It is the Set rng = ... that fails if search is unsucessful. Very thakful
for fast assistance.