Thank you, everybody. This has solved my problem, and given me a lot to think about (especially the suggestion "Avoid using VBA-code you do not understand.")