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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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