Consulting

Results 1 to 2 of 2

Thread: erase #value!

  1. #1

    erase #value!

    Hi,

    I have this code

    function number( n as double) as double

    number=n+1

    end function


    Simple

    Now I want; if someone decide to put a string instead a double in the cell to show something like msgbox("error") and erase #value!

    Please help me!

    Thx

  2. #2
    VBAX Regular
    Joined
    Feb 2009
    Posts
    16
    Location
    Quote Originally Posted by ratvoleur
    Hi,

    I have this code

    function number( n as double) as double

    number=n+1

    end function


    Simple

    Now I want; if someone decide to put a string instead a double in the cell to show something like msgbox("error") and erase #value!

    Please help me!

    Thx
    One easy way (not sure it is the best) is to do the following:
    Function number(n As Variant) As Variant
    
    If IsNumeric(n) Then
       number = n + 1
    Else
       Call MsgBox("Error", vbCritical )
       number = ""
    End If
    
    End Function

Posting Permissions

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