When I try to use the VBA function that I defined in the Excel spreadsheet, I get "This is not a valid function",

I defined a function in VBA as follows

Public Function Distance(X, Y) as Double

Then in the cell I try to use this function. I type "@Dis" and get a drop-down menu, select a function, and then enter the parameters ending in @Distance (A1, A2) in the cell.

When I press Enter, I get the error message "This function is not valid."

I turned on macros throughout the system, tried to save it as an old format and as a workbook format with macro support to no avail.

What happened to my use of this feature?

+5
source share
3

:

=Distance(A1, A2)

@Distance(A1, A2)

@ Excel.

Excel, :

1:

Public Function Distance(X as Double, Y as Double) as Double
    Distance = 10
End Function

:

=Distance(A1, A2)

:

10

.

+6

, VBA Module, .

+6

Do not use reserved words as the names of your functions. I tried one name Parse () and it threw it back until I renamed it to ParseString ().

+3
source

All Articles