Excel VBA Forms
Now add a textbox by clicking on the AB| control in the toolbox that appeared when you inserted the form. Also, in the same way, add a Command Button.
(Click the arrow control at the upper left of the Toolbox to return the mouse pointer if the mouse is trying to draw a control.)
Double click the Command Button to open the code editor with an empty Sub routine for the button and add the line Userform1.Hide , this wll close the form
Private Sub CommandButton1_Click()
To open your the form, double click on ThisWorkbook in the VBAProject Explorer and then choose Workbook at the upper left of the code window.
The Workbook methods now appear to the right and the default "Open should have been selected. Add the line UserForm1.Show . This will display the form when the workbook is opened.Private Sub Workbook_Open()
Save and close the workbook then reopen. The form appears. Clicking the button now closes the form.
You can create more userforms and use Command Buttons to open them.
This site is powered by Site Build It!. If you enjoy it, please check out the
Site Build It homepage to learn more and on how to build a success-guaranteed site with no technical skills.