ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find (https://www.excelbanter.com/excel-programming/406231-find.html)

ranswert

find
 
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

Dave Peterson

find
 
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
....



ranswert wrote:

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


--

Dave Peterson

ranswert

find
 
Thanks I'll try that

"Dave Peterson" wrote:

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
....



ranswert wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com