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?
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,032
Messages
5,569,764
Members
412,291
Latest member
marypolitan
Top