UserForm Basics #1

Here, you’ll learn to make a UserForm, add a button, and make clicking on that button hide the UserForm!

Make a UserForm:

  1. Press Alt-F11 to bring up Visual Basics menu
  2. Click the drop down menu in the upper left hand and select UserForm:Screen Shot 02-10-16 at 11.46 PM
  3. Press F4 to bring up the properties menu. Use this box to change the userform’s name:Screen Shot 02-10-16 at 11.56 PM
  4. Next, use the “Caption” field to change the UserForm’s caption:Screen Shot 02-11-16 at 12.02 AM

 

Add a Button:

  1. Using the Toolbox Controls, add a Command Button:Screen Shot 02-11-16 at 12.05 AM
  2. In the UserForm area, single click to create a standard size button, or click and drag to create the button size you want:Screen Shot 02-11-16 at 12.15 AM
  3. Click on the button’s text to edit it’s display text:Screen Shot 02-11-16 at 12.16 AM
  4. Using the properties menu on the left, you can change the button’s color, font, and other properties!

Hiding the UserForm when the button’s pressed!

  1. Double-click on your Command Button (or whatever you’ve named it in the properties menu), to bring up the event script menu.
  2. Use the command “.Hide” as shown in the picture below. In this example, the UserForm’s name was HideForm, thus the script line is “HideForm.Hide”:
  3. Private Sub btnHide_Click()
    HideForm.Hide
    End Sub

Check out the video below for more details!