plan_date As Date
Is your Type Mismatch. You are passing a range to the UDF in the function.
plan_date As Range
There is so much wrong. I can debug it if you post the full UDF