Hiding a UserForm without losing data

tungchiu

New Member
Joined
Nov 20, 2005
Messages
34
Hi all!
I have placed a 'Print Preview' button on my UserForm. I need code please to hide or minimize the UserForm while the preview window is open. If maximize/minimize is not possible, I presume that I will need to place a button on the spreadsheet to show the UserForm again. I am not sure how to do this without losing the data. Any ideas?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
The PrintPreview window is application modal. Therefore, the following code would Hide the userform, show the print preview window, and then show the userform again when the Print Preview window is closed. The Hide method does not unload the userform and, therefore, your data is still intact. If this is not your answer then please explain your problem in a different light. Post your applicable userform code.

Code:
Private Sub CommandButton1_Click()
    Me.Hide
    ActiveWindow.SelectedSheets.PrintPreview
    Me.Show
End Sub

Tom
 
Upvote 0
Thanks Tom - so simple! Something else - how can I have my user form appear automatically when the workbook is opened?

Rangi
 
Upvote 0
Place in the workbook open event procedure...


Code:
Private Sub Workbook_Open()
    YourUserform.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

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