Your function is not good and it works with array but not sheet Range.
Why build your trouble function while you already have WorksheetFunction PERCENTILE() that do the samething for you?
=PERCENTILE("A1:A20", 0.95)