Forum Discussion
Excel userforms
- Dec 30, 2020
I don't see an attachment in your reply.
See the attached workbook. The userform is displayed modeless, and it gets its data from and stores them on the Data sheet.
A userform is volatile - when you close it, the values of its text boxes etc. are gone. So if you want to keep those values, you have to store them elsewhere - in cells on a worksheet, or in custom document properties, or in the Windows Registry (if you're on Windows), or in a separate file.
By default, a userform is modal. This means that the user cannot interact directly with the workbook while the userform is open. So the user cannot click on a command button on a worksheet.
It is possible to open a userform modeless. The user can then interact with the workbook while the userform is open, including clicking on a command button. It might be confusing if the user edits cells while the userform is open; it's up to you to decide whether that is a problem.
Thank you very much for replying so promptly.
I'm not sure if you implied or did not as to whether you know how to or not, but do you know how I can store info on, say, the spreadsheet which can then be viewed on a userform as well, so it looks like it's being stored on the userform. And if I were to change something, then the info on the spreadsheet will also update itself.
Also, could you explain to me how to make a userform modeless so I can interact with the workbook while the userform(s) are open? I have included a template database sheet that 'stores' data inserted into it.
- HansVogelaarDec 30, 2020MVP
I don't see an attachment in your reply.
See the attached workbook. The userform is displayed modeless, and it gets its data from and stores them on the Data sheet.
- Shaya5Dec 31, 2020Copper Contributor
Once again, thank you very much for your time and invaluably helpful information
Would you be able to explain how you made the form so that I can still interact with the actual spreadsheet while the userform is open?
Thank you very much
- HansVogelaarJan 01, 2021MVP
The macro in Module1 that opens the userform has this line:
UserForm1.Show False
The False argument tells Excel to open the userform modeless.
I also set the ShowModal property of the userform to False, so that it is opened modeless when you run it directly from the Visual Basic Editor.