Hello and welcome to the forum. What is val in your last formula? Is this a user-defined function because Excel doesn't seem to recognize it.

abousetta