+ Reply to Thread
Results 1 to 3 of 3

Declaring errors

Hybrid View

  1. #1
    Registered User
    Join Date
    11-03-2006
    Posts
    6

    Declaring errors

    Hey, everyone. I'm need to differentiate between #DIV/0! errors and other errors on a regular basis. Since there is no function comparable to ISNA(), I've put together a simple UDF to serve my purpose. Here's what my ISDIV0() function looks like:

    Function isdiv0(Value as String)
    Dim BoValue As Boolean
    
        
    
        If Value = "#DIV/0!" Then
        BoValue = True
        Else
        BoValue = False
        End If
        isdiv0 = BoValue
        
    End Function
    If I point this at a cell with a #DIV/0! error, then I get a #VALUE! error. However, if I point it at a cell in which I've typed #DIV/0!, then it works perfectly. All I can figure is that errors cannot be manipulated as strings.

    Can anyone help me figure out how to properly pass the error into my function? I tried digging through excel VBA object editor to see how ISNA() works, but I can't get down to the actual code.

    Thanks!

  2. #2
    Registered User
    Join Date
    11-03-2006
    Posts
    6
    Does anyone know if taking he value of the cell as text as they did here:

    http://www.excelforum.com/showthread.php?t=611166

    would work?

  3. #3
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302

    Cell Error Values - Testing and Setting in VB Help

    Look at VB Help under Cell Error Values, where the following appears:

    This example displays a message if the active cell on Sheet1 contains a cell error value. You can use this example as a framework for a cell-error-value error handler.
    Worksheets("Sheet1").Activate
    If IsError(ActiveCell.Value) Then
        errval = ActiveCell.Value
        Select Case errval
            Case CVErr(xlErrDiv0)
                MsgBox "#DIV/0! error"
            Case CVErr(xlErrNA)
                MsgBox "#N/A error"
            Case CVErr(xlErrName)
                MsgBox "#NAME? error"
            Case CVErr(xlErrNull)
                MsgBox "#NULL! error"
            Case CVErr(xlErrNum)
                MsgBox "#NUM! error"
            Case CVErr(xlErrRef)
                MsgBox "#REF! error"
            Case CVErr(xlErrValue)
                MsgBox "#VALUE! error"
            Case Else
                MsgBox "This should never happen!!"
        End Select
    End If
    FrankBoston is the pen name for Andrew Garland, Lexington MA

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1