find

R

ranswert

I have the following code:

With rng
Set xcell = .find(what:=drwno, LookIn:=xlValues,
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)
a = xcell.Offset(0, 10).Value
xcell.Offset(0, 10).Select
If a <> linkno Then
cnt = 0
Do
cnt = cnt + 1
Set xcell = .FindNext(xcell)
a = xcell.Offset(0, 10).Value
Loop While a <> linkno And cnt < drwitemnum + 1
xcell.Select
End If
End With

How do I get the procedure to skip 'find' if there is no 'drwno' in the range?
Thanks
 
D

Dave Peterson

With rng
Set xcell = .find(what:=drwno, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns)

if xcell is nothing then
'not found, what happens
exit sub 'maybe???
else
a = xcell.Offset(0, 10).Value
....
 
R

ranswert

Thanks I'll try that

Dave Peterson said:
With rng
Set xcell = .find(what:=drwno, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns)

if xcell is nothing then
'not found, what happens
exit sub 'maybe???
else
a = xcell.Offset(0, 10).Value
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Loop 3
error 5
Listbox problem agaie 3
Find the correct sheet then find a value on that sheet 8
commandbutton does not answer 0
Listbox problems 3
intersect 12
Make VBA ComboBox_Change work in 3 sheets 1

Top