VBAString Tip 8: How To Create A Simple UserForm

In this tip I am going to show you how to create a simple userform in Excel

You are going to find out how to show the userform and transfer the data from your userform
to your worksheet.

If you want more advanced userform tips, click on the “UserForm” category on the right of the screen.

1. Right click in the VBE, and insert a UserForm.

add_userform

Use the toolbox to add 2 controls for “First Name” and “Last Name”. Add a 3rd control, a command button, to enter into the worksheet the values from the userform.

Add a button to the worksheet, to show the userform.

The macro code is:

Sub Button1_Click()
    UserForm1.Show
End Sub

Add this code to the “Enter” button:

Private Sub btnEnter_Click()
    Range("A1") = Me.txtFname
    Range("B1") = Me.txtLname
    
End Sub

That’s all. Now watch how it’s done:

Let me know if you have any questions:

[simple_contact_form]


Posted

in

by

Tags: