I tested Macieps' code and it worked fine for me. No need for another UDF either as his includes all that is needed.