Close just one Userform with X

miami2k

New Member
Joined
Nov 1, 2017
Messages
48
Dear All, I have a userform with a button that opens another userform. Once the user has finished to use the second userform, he is supposed to close it with the X at the top right.
This unfortunately closes also the first userform. The first one should remain open and the user should be abele to keep working on it.
I considered the option to reload the first userform but I was wondering if there is option to avoid this because the first userform on restart is resetted and I would like the user to be able to continue from where he left when he opened the second on.

Thank you in advance.
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,557
What is the code in the first workbook that opens the second?
What is the code in the second that closes itself (hopefully only itself)? Or does the second userform only have the corner X and no Close button?
 

miami2k

New Member
Joined
Nov 1, 2017
Messages
48
Mike, this is the code to launch the second userform

Private Sub CommandButton13_Click()

EditTimesheet.Show

End Sub

and so far there is only the X and no Close button (if I find a solution, I might not need it).
Another option could be to disable the X and add a Close button with a code that does not close the first userform but I did not try that yet.

Thanks
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,557
I can't replicate your error. But in my testing the corner X in the second userform appeared directly above the corner X of the first userform.

It might be possible that you are inadvertently (UI glitch?) double clicking and the second click is what closes the first form.

Try putting this code in the code module for the second form

VBA Code:
' in code module for userform EditTimeSheet

Private Sub UserForm_Activate()
    With Me
        .Top = .Top + 15
        .Left = .Left + 15
    End With
End Sub
 

miami2k

New Member
Joined
Nov 1, 2017
Messages
48
I think you are right. The windows are one over the other... I prob clikked twice. Nice guess!! Thanks!
 

Watch MrExcel Video

Forum statistics

Threads
1,099,121
Messages
5,466,812
Members
406,499
Latest member
ToyoMike

This Week's Hot Topics

Top