Thanks both,
I'd tried the quit before, but I think my IF statement was preventing the MyXl value from being set. When I get rid of it, the Quit function works correctly.
MD