Contain information in userform

noexcelguru

New Member
Joined
Jan 18, 2011
Messages
40
Hi,
Is it possible to save the data that has been entered in a textbox within a userform so the information still will be in there after you close it? I'm using the .Hide command, but mabye there is a code that just sends the userform to the back without closing it?

If not, is it possible to add an excelsheet in a userform? Will this save the data?

Other suggestions how to save the data without unloading the form is of course welcome.
Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You could change the .top property of the form so it's a higher value than your visible screen height. It won't be visible but it will still be active. Of course, this will only work if the .showmodal is false.

Also, are you using .activate or .initialize event to set up your form in the first place? I think that if you do it all using .initialize, then .hide & .show won't reset the values, as these events don't trigger the .activate code.
 
Upvote 0
Thanks for your input, Weaver

You could change the .top property of the form so it's a higher value than your visible screen height. - I tried that, however it only sent the userform to the far edge of the screen, covering my workbook. I did not use .showmodal as i'm not familiar with this function. Like this?

Private sub workbook_activate()
Application.showmodal = False
End sub

If i change the .top property, will i still be able to access the userform, or is "lost" way beond the monitors reach?

Also, are you using .activate or .initialize event to set up your form in the first place?
To show the userform:

Private Sub CommandButton4_Click()
UserForm4.Show
End Sub

I tried swapping .Show with .Initialize, but i got a Compile error: Method or data member not found

Thanks again
 
Upvote 0
Sorry, I wasn't refering to how you opened the form

When a form is opened, it triggers certain events, such as those I mentioned. The code will be in the form itself. Some developers use these events to prime their forms with certain values, such as populating a list box.

so you might get
Code:
Private Sub UserForm_Activate()
    txtOp = 0
    chkDbar = False
    chkBackup = True
end sub
for example. I figured you were doing this, but with an initialize event, since usually just hiding a userform doesn't reset its values, they only get reset when reinitializing, and then only through code.

If you change the .top property, you'll need to reset it, this is something you could do with the commandbutton code. So if you'd set it to 100 previously, the commandbutton code could set it back to 200 or whatever you're comfortable with.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,551
Members
452,927
Latest member
rows and columns

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