Consulting

Results 1 to 4 of 4

Thread: Sleeper: IsError

  1. #1
    VBAX Regular
    Joined
    Mar 2005
    Posts
    31
    Location

    Sleeper: IsError

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    As help says, IsError Returns a Boolean value indicating whether an expression 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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Mar 2005
    Posts
    31
    Location
    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?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by IVY440
    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?

    Quote Originally Posted by IVY440
    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
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •