Save & Retrieve data to userforms


Posted by Ron on June 06, 2001 7:38 AM

I'm looking for a suggestion..........
I have a group of userforms that collect 80-100 pieces of data, perform calculations, and place the caluclated data onto sheets to be printed as reports. When the workbook is saved, the userforms are cleared when the workbook is reopened. I would like to be able to save the data entered and repopulate the userforms when the workbook is reopened so the user may make a change or two without entering all the data again.

Any ideas??? Thanks.



Posted by Damon Ostrander on June 06, 2001 10:26 PM

Ron,

I recommend just writing the state of each control to a worksheet set aside for this purpose (could be a hidden sheet). Writing it to a worksheet ensures that it will survive the close and re-open process.

Every control has a property that represents its state (e.g., a TextBox has a Value property). Just write the control properties you want to save to worksheet cells, and restore them using the UserForm's Initialize event when you Show the form, reading the data from the worksheet cells to the UserForm's control properties. I recommend that you name the worksheet cells to correspond to the controls you are saving.

Damon