Show UserForm in New Workbook

devilishblueyes

New Member
Joined
Oct 18, 2007
Messages
18
Here's where I'm at...

I initially show UserForm1 in the window for Book1. The user enters values into the textboxes of UserForm1 then clicks CommandButton1. The subroutine for CommandButton1 checks that the active workbook is the correct form. If not, it opens a new workbook using Workbooks.Add and it creates a new workbook called Book2 from a template.

Here's my problem...

UserForm1 is still being shown in the Excel Window for Book1. I want UserForm1 to now be shown in the Excel Window for Book2.


Currently if I activate Book2, UserForm1 is now hidden away in the window for Book1. If I show UserForm1, then the window for Book2 is now hiding below the window for Book1. And I'm wanting to avoid closing UserForm1 so that I don't lose the values in the textboxes.

Is there anyway I can change the window that UserForm1 is displayed in from Book1 to Book2 without losing the values in the textboxes?
 

Jerry Sullivan

MrExcel MVP
Joined
Mar 18, 2010
Messages
8,787
In the scenario in which Book1 is not in the correct form and Book2 is opened, what do you want to do with Book1?
 

devilishblueyes

New Member
Joined
Oct 18, 2007
Messages
18
In that scenario, I want to leave Book1 completely alone and do nothing to it because that may be a totally different kind of file that the user most likely does not want to change at all. So my thought would be to leave Book1 open and do nothing to Book1, add Book2 change the focus of the program completely to Book2, make the changes to Book2 and finish up with Book2 as the active Excel window and with UserForm1 open in the Book2 window with all of the values entered on the form still entered on the form. My UserForm is pretty complex and it has Click and Change events associated with some of the combo boxes and text boxes. So I'm trying to avoid capturing all of the form values, Unloading the form, activating Book2 then reloading UserForm1 and repopulating the values of all of the UserForm1 objects which would likely trigger event procedures.
 

Forum statistics

Threads
1,082,641
Messages
5,366,717
Members
400,915
Latest member
NFlem

Some videos you may like

This Week's Hot Topics

Top