VBA function works within a sub procedure but not on the excel worksheet: value error. Probably an i