|
-
Aug 1st, 2006, 03:39 PM
#1
Thread Starter
Member
[RESOLVED] Range.find
Ok, right now I have a range.find method to try to...well...find some data...but it keeps giving me an error when the data I'm searching for isn't there.
VB Code:
If IsNull(Cells.Find(What:=Worksheets("Open Orders").Cells(i, 1), After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate) = True Then
Sheets("Open Orders").Cells(i, "N") = 0
Else
Sheets("Open Orders").Cells(i, "N") = ActiveCell.Offset(0, 34)
End If
Now, I'm assuming I'll have to change that IsNull to something else to be able to catch it, but I'm not sure what I have to change it to, or if that's even the right direction to go in.
-
Aug 1st, 2006, 08:29 PM
#2
Re: Range.find
empty cells don't return null, cells won't accept null
they are = vbnullstring or ""
VB Code:
If Sheets("Open Orders").Cells(i, 1) = "" Then
Sheets("Open Orders").Cells(i, "N") = 0
Else
Sheets("Open Orders").Cells(i, "N") = ActiveCell.Offset(0, 34)
End If
pete
-
Aug 1st, 2006, 08:33 PM
#3
Thread Starter
Member
Re: Range.find
Hmm...that's not quite what I'm trying to do. The Cells(i, 1) holds a value that I'm trying to find in a different worksheet. The only problem is, occasionally there's a value that's not in the worksheet that I'm searching, and when that happens, the Range.find function throws an error...91 I think. What I'd ultimately like to do is to put a zero in the Cells(i, "N") if the error occurs, meaning that there was no match found.
-
Aug 1st, 2006, 08:48 PM
#4
Re: Range.find
trap the error with an error handler?
before where you expect the error putstraight above end sub put
VB Code:
exit sub
onerror:
if error.number = 91 then cells(i,"N")=0
pete
-
Aug 1st, 2006, 08:49 PM
#5
Thread Starter
Member
Re: Range.find
That makes sense. I'll try it out tomorrow and see if I can get it to work. Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|