You created a Function procedure, but terminated it with the End keyword, instead of the End Function statement. A Function procedure must include a terminating End Function statement.
To correct this error
-
Terminate your Function procedure with the End Function statement.