PDA

View Full Version : Sleeper: IsError



IVY440
08-11-2005, 11:23 AM
Can anybody explain me how the IsError function exactly works?
I still want to check if a city is already in a list and I had the idea to do it with IsError, but it seems that's someting is always going wrong :think:

Bob Phillips
08-11-2005, 01:07 PM
As help says, IsError Returns a Boolean value indicating whether an expression (javascript:hhobj_4.Click()) is an error value. Unfortuantely, not all expressions return an error value, they might abort. For instance Application.function_name works okay (mainly) with IsError, WorksheetFunction.function_name genearlly does not.

Personally, I avoid IsError in favour of On Error Resum Next:code:On Error Goto 0, unless I just want to know if say a Match function works.

IVY440
08-12-2005, 12:53 AM
The problem is that the help on my computer at the office isn't installed and the guy with the cd's is not here this week, so I'm asking it this way.
What does the Match function do?
The purpose is that a value is being checked if it appears in a list. Can I do it with the Match function?

Bob Phillips
08-13-2005, 09:48 AM
The problem is that the help on my computer at the office isn't installed and the guy with the cd's is not here this week, so I'm asking it this way.

What bright-spark thought up that policy, have the product but not the help?


What does the Match function do?
The purpose is that a value is being checked if it appears in a list. Can I do it with the Match function?

Match looks in an array for a particular value, and returns its index within that array if found.

So, yes, Match will do it fine.

Something like



Dim iPos As Long
Dim myVal
myVal = "some lookup value"
On Error Resume Next
iPos = Application.Match(myVal, Range("A1:A20"), 0)
On Error GoTo 0
If iPos > 0 Then
MsgBox "found"
Else
MsgBox "not found"
End If