@JvdV, your solution works, but it also returns duplicate values. Would you please modify the formula to remove duplicate values.