The codes being executed must include instructions for the userform to close for that to happen. Remove those instructions.