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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
L

Legacy 98055

Guest
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
 

tungchiu

New Member
Joined
Nov 20, 2005
Messages
34
Thanks Tom - so simple! Something else - how can I have my user form appear automatically when the workbook is opened?

Rangi
 
L

Legacy 98055

Guest
Place in the workbook open event procedure...


Code:
Private Sub Workbook_Open()
    YourUserform.Show
End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,117
Messages
5,857,477
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

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
Top