S
Subodh
I need to create a function in VBA Excel.
The code is like this
Function mysub(x as variant) as variant
..................... code goes here ...............
end function
Now if the user enters code mysub(somestring)
or something like that then there is a error message in the Excel Cell
But, I want to get the excel cell not to display such error.
I tried to get the type but it didn't work fine
My code goes like this.
Function newfun(agrus As Variant) As Variant
Dim x As Variant
newfun = argus * agrus
Exit Function
'If IsMissing(argus) Then
'newfun = argus & "No argument in the function"
'Else
x = TypeName(argus)
Select Case x
Case "Range"
newfun = argus & "Cannot take range as argument. Enter Single
cell value"
Case "Null"
newfun = argus & "You didn't entered an argument. Must have
one argument."
Case "Error"
newfun = argus & "You entered a error value. Check the value."
Case "Boolean"
newfun = argus & "You entered boolean value."
Case "Empty"
newfun = argus & "Empty value."
Case Else
newfun = argus & "Other data types. " & TypeName(argus)
End Select
'End If
'newfun = argus & "No you can make a start"
'End If
End Function
Can anyone help
The code is like this
Function mysub(x as variant) as variant
..................... code goes here ...............
end function
Now if the user enters code mysub(somestring)
or something like that then there is a error message in the Excel Cell
But, I want to get the excel cell not to display such error.
I tried to get the type but it didn't work fine
My code goes like this.
Function newfun(agrus As Variant) As Variant
Dim x As Variant
newfun = argus * agrus
Exit Function
'If IsMissing(argus) Then
'newfun = argus & "No argument in the function"
'Else
x = TypeName(argus)
Select Case x
Case "Range"
newfun = argus & "Cannot take range as argument. Enter Single
cell value"
Case "Null"
newfun = argus & "You didn't entered an argument. Must have
one argument."
Case "Error"
newfun = argus & "You entered a error value. Check the value."
Case "Boolean"
newfun = argus & "You entered boolean value."
Case "Empty"
newfun = argus & "Empty value."
Case Else
newfun = argus & "Other data types. " & TypeName(argus)
End Select
'End If
'newfun = argus & "No you can make a start"
'End If
End Function
Can anyone help