i tested before i posted

i used your same values, in 2 cells of work sheet
put your formula into 3rd cell for control

i read the cells into an array an passed to your function
which when modified returned the same results as the worksheet formula