Close just one Userform with X

miami2k

Board Regular
Joined
Nov 1, 2017
Messages
58
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.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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?
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
I think you are right. The windows are one over the other... I prob clikked twice. Nice guess!! Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top