Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Anders
you have defined the function as returning a double yet if either paramenter is not a number you try to return a string. I suggest you define the function as returning a variant i.e.: Public Function anders_test(roof As Variant, tail aAs Variant) as Variant Fred "Anders" wrote in message ... Hi all helpful experts :-). I would like a form to produce a function call to a home made VBA function. I don't want to call the function directly from the form since I want to be able later to use all nice internal functions as copy cell, drag drop, extend etc. I have made this silly VBA function in a module: Public Function anders_test(roof As Variant, tail As Variant) As Double If IsNumeric(roof) And IsNumeric(tail) Then anders_test = roof / tail Else anders_test = "Invalid input" End If End Function I have made a form with this content under an OK button: Private Sub cmdOK_Click() ActiveCell.Value = "=anders_test(b6;b6)" End Sub When I try to run this I get the error message 1004, Application-defined or object-defined error. If I try to save a normal value in the activecell.value like activecell.value = "test", everything works. Can anyone help me? Kind regards Anders |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a do not call function? | Excel Discussion (Misc queries) | |||
How do I call this function? | Excel Programming | |||
how i can call the function | Excel Worksheet Functions | |||
call a function from VBA | Excel Programming | |||
Function Call | Excel Programming |