![]() | |||
Excel VBA FormsYou can create Excel VBA forms (Excel VBA userforms) in the VBA editor which you display while the workbook is open. To start, open the editor, right click on Microsoft Excel Objects in the VBAProject Explorer at the upper right. choose Insert Userform.![]() 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() UserForm1.Hide End Sub To open your Excel VBA form, double click on ThisWorkbook in the VBAProject Explorer and then choose Workbook at the upper left of the code window. ![]()
UserForm1.Show End Sub 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. . Return from Excel VBA Forms to VBA Code Samples
| |||