Un-hiding userform

colosgps1975

New Member
Joined
May 30, 2002
Messages
49
My entire workbook coding is rather complicated, but here is my problem:

A button on UserForm1 in Workbook1 opens a new Workbook (Workbook2) based on textbox values in UserForm1. Prior to opening Workbook2, I hide UserForm1. Then I can fill in WorkBook2 as needed. I have a button in Workbook2 that saves the workbook and exits. Now, I return to WorkBook1. I need to 'unhide' UserForm1. There are values in UserForm1 that I need, so I can't unload it. But upon returning to WorkBook1, if I do a UserForm1.show command, I then have 2 UserForm1's loaded.
Any ideas? Thanks to all. This board is awesome.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I can't reproduce your problem.

I ran this code:

Code:
Sub ShowForm()
    UserForm1.Show
End Sub

to show a UserForm with a TextBox, two CommandButtons and the following code:

Code:
Private Sub CommandButton1_Click()
    UserForm1.Hide
End Sub

Private Sub CommandButton2_Click()
    MsgBox UserForms.Count
End Sub

No matter how many times I click CommandButton1 and rerun the ShowForm procedure, clicking CommandButton2 only returns 1 (UserForm loaded).
 
Upvote 0
If I enter something in the TextBox and click CommandButton1 to hide it, it's still there when I show it again.

Do you have something in the Userform's Activate event procedure that is resetting the controls?
 
Upvote 0
Thanks for the reply. I did have activation events. But I worked around it by placing a value in a cell. Then when the userform activates, if that cell contains that value, it bypasses the code and resets the number. Works great now. Thanks again.
 
Upvote 0
If you use the Initialize event instead of the Activate event, it will only fire when you first show the UserForm (ie it is Loaded).
 
Upvote 0

Forum statistics

Threads
1,203,673
Messages
6,056,675
Members
444,881
Latest member
Stu2407

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