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.
Function Statement | Call Statement | Dim Statement | Exit Statement | Set Statement | Sub Statement