Sorry Dave, there was a typo in my code. Everything works fine with Ulrich’s function. Thank you all for your help.