It is easy to create your own user form in Microsoft Excel.

Lets begin to create a simple calculator.

I have also included Form to automate the database (Automate Survey) in excel sheet from STEP 6 onward.


Just open Microsoft Excel.

Press"Alt + F11 " that will open a Visual Basic window.

Select UserForm from Insert menu. That will open a User form window like above

Step 2: ​Controls and the Toolbox

The Controls for a UserForm can be found on what is known as the "Toolbox". When we Insert a UserForm from within the VBE (Visual Basic Environment) via Insert > UserForm the Toolbox will be displayed by default. Or we can go to View>Toolbox. The Toolbox contains a single page tab aptly called "Controls". It is here that we will see all the Visual Basic controls plus any ActiveX Controls that may have been added. By default there will be sixteen Controls available these are:















15.Select Objects


Step 3: Drag and Place Tools to Useform

In the VBAProject under the form a form with default name UserForm1 will appear select that User form .

Then a user form window appear.

The size of the window can be adjusted.

Drag and drop the Command Button in the useform.Use command Button for each operators.

This can be done in a simple way by just copy a button by Ctrl+C and pasting by Ctrl+V.

Then change the size of button to make then somewhat look like a calculator.

Then change the Caption of each button from the properties.

Just right click on button >Properties > Caption .Change the caption of each button.

Also add TextBox tool to userform ,which can be used to type the operands

We can add a Background image by selecting an image file usually jpeg files from a file.

i.e Select Userform then right click on the form >Properties> image then select a picture

Step 4: Type the Code for Each Tools

Select each CommandButton . and type the code for each buttons .

My code is given below , please note that the Command Button caption will be different.

Please see that caption for each command button. Double click on the commandButton and type code for each of the commands

Private Sub CommandButton14_Click()

'Addition operator

Ans.Text = Val(Op1.Text) + Val(Op2.Text)

End Sub

Private Sub CommandButton30_Click()

'Plus or minus operator

Ans.Text = -Ans.Text

End Sub

Private Sub CommandButton31_Click()

If (Val(Op2.Text) = 0) Then

'Division operator

Ans.Text = "Division by Zero"

Exit Sub


Ans.Text = Val(Op1.Text) / Val(Op2.Text)

End If

End Sub

Private Sub


'Multiplication operator

Ans.Text = Val(Op1.Text) * Val(Op2.Text)

End Sub

Private Sub CommandButton33_Click()

'Minus operator

Ans.Text = Val(Op1.Text) - Val(Op2.Text)

End Sub

Private Sub CommandButton35_Click()

'Square root operator

Ans.Text = Ans.Text ^ (1 / 2)

End Sub

Private Sub CommandButton37_Click()

'1/x operator

If (Val(Ans.Text) = 0) Then

Ans.Text = "Division by Zero"

Exit Sub


Ans.Text = 1 / (Ans.Text)

End If

End Sub

Private Sub CommandButton38_Click()

Ans.Text = 0

End Sub

Private Sub UserForm_Click()

End Sub

In order to automatically open the UserForm when excell is opened type the following code in the ThisWorkbook

Private Sub Workbook_Open()


End Sub

Step 5: Make Your Own Calculator

You can add many features to this and make your own calculator.

We can do it in Visual studio in same way and can create .exe files.

Thanks and please please vote for this if you like.

Step 6: Make Your Own User Form to Automatically Update the Data in Excel

You can create your own Form to enter Family data , that automatically update your excel sheet by following steps.

Step 7: Add the Controls

To add the controls to the User-form, execute the following steps.

1. Open the Visual Basic Editor. If the Project Explorer is not visible, click View, Project Explorer.

2. Click Insert, Userform. If the Toolbox does not appear automatically, click View, Toolbox. Your screen should be set up as below.

Userform Screen Setup in Excel VBA

3. Add the controls list as in the picture . Once this has been completed, the result should be consistent with the picture of the Userform shown earlier. For example, create a text box control by clicking on TextBox from the Toolbox. Next, you can drag a text box on the Userform. When you arrive at the Car frame, remember to draw this frame first before you place the two option buttons in it.

4. Change the names and captions of the controls according to the table below. Names are used in the Excel VBA code. Captions are those that appear on your screen. It is good practice to change the names of controls. This will make your code easier to read. To change the names and captions of the controls, click View, Properties Window and click on each control.

Step 8: Show the Userform

To show the Userform, place a command button on your worksheet and add the following code line:

Private Sub CommandButton1_Click()


End Sub

We are now going to create the Sub UserForm_Initialize. When you use the Show method for the Userform, this sub will automatically be executed.

1. Open the Visual Basic Editor.

2. In the Project Explorer, right click on Family_Form and then click View Code.

3. Choose Userform from the left drop-down list. Choose Initialize from the right drop-down list.

4. Add the following code lines:

Private Sub UserForm_Initialize()

'Empty NameTextBox

NameTextBox.Value = ""

'Empty PhoneTextBox

PhoneTextBox.Value = ""

'Empty CityListBox CityListBox.Clear

'Fill CityListBox

With CityListBox

.AddItem "Kochi"

.AddItem "Mumbai"

.AddItem "Delhi"

.AddItem "Agartala"

.AddItem "Agra"

.AddItem "Agumbe"

.AddItem "Ahmedabad"

.AddItem "Aizawl"

' you can add your other cities here

End With

'Empty StatusComboBox


'Fill StatusComboBox

With StatusComboBox

.AddItem "Lower Class"

.AddItem "Middle Class"

.AddItem "Upper Class"

End With

'Uncheck DataCheckBoxes

'Set no car as default

CarOptionButton2.Value = True

'Empty Members

Members.Value = ""

'Set Focus on Name

TextBox NameTextBox.SetFocus

End Sub

Step 9: Assign the Macros

We have now created the first part of the Userform. Although it looks neat already, nothing will happen yet when we click the command buttons on the Userform.

1. Open the Visual Basic Editor.

2. In the Project Explorer, double click on Family_Form.

3. Double click on the Member button.

4. Add the following code line:

Private Sub MemberButton_Change()

MoneyTextBox.Text = MoneySpinButton.Value

End Sub Explanation: this code line updates the text box when you use the spin button.

5. Double click on the OK button.

6. Add the following code lines:

Private Sub

Members.Text = MemberButton.Value

End Sub

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Sheet1 active Sheet1.Activate

'Determine emptyRow

emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1

'Transfer information

Cells(emptyRow, 1).Value = NameTextBox.Value

Cells(emptyRow, 2).Value = PhoneTextBox.Value

Cells(emptyRow, 3).Value = CityListBox.Value

Cells(emptyRow, 4).Value = StatusComboBox.Value

If CarOptionButton1.Value = True Then

Cells(emptyRow, 6).Value = "Yes"


Cells(emptyRow, 6).Value = "No"

End If

Cells(emptyRow, 7).Value = Members.Value

End Sub

Explanation: first, we activate Sheet1. Next, we determine emptyRow. The variable emptyRow is the first empty row and increases every time a record is added. Finally, we transfer the information from the Userform to the specific columns of emptyRow.

7. Double click on the Clear button.

8. Add the following code line:

Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub

Explanation: this code line calls the Sub UserForm_Initialize when you click on the Clear button.

9. Double click on the Cancel Button.

10. Add the following code line:

Private Sub CancelButton_Click()

Unload Me

End Sub

Explanation: this code line closes the Userform when you click on the Cancel button.

Step 10: Test the Userform

Exit the Visual Basic Editor, enter the labels shown in the picture into row 1 and test the Userform.

<p>Thank you so much for this instructable - it is exactly what I need. I have a question for you - is it possible to do the reverse - also in the same form? For instance, I track telecom tickets which come into our ticketing system and enter them into excel. I would like to be able to VLOOKUP (or equivalent) in the form you created and I modified and then have it populate the fields based on the corresponding data in Excel. This would allow me to switch the &quot;Status&quot; field from 'Open' to 'Resolved'. I would like to then be able to then re-submit/save the newly edited data back into the spreadsheet.<br><br>Does this make sense, and is it possible without VBA?<br><br>I am basically trying to avoid using Microsoft Access! :)<br><br>Thank you again</p>
Super instructable
<blockquote>I have also included Form to <strong>automate the database (Automate Survey) in excel sheet </strong>from <strong>STEP 6 </strong><strong>onward</strong><strong>.</strong></blockquote>
<blockquote><strong>Thank-you all for your comments and Do supporting me</strong></blockquote>
<p>Sorry , that is German. I little weak in English. My question is there is any way to include vedio in excel form .</p>
<p>Its good to hear from you! We cann't directly include video like picture , which i have included in my Form. But you can play video by adding a link to the form </p><p>First create a button and double click on the button , then add the following code.</p><blockquote><strong><em>Dim WMP as <br>Object</em></strong></blockquote><blockquote><strong><em>Set WMP = <br>CreateObject(&quot;new:{6BF52A52-394A-11d3-B153-00C04F79FAA6}&quot;)</em></strong></blockquote><blockquote><strong><em>Wmp.OpenPlayer &quot;C:\Users\Public\Videos\Sample <br>Videos\Wildlife.wmv&quot;<br><br></em></strong>First create a button and double click on the button .<br><br>If you want to play Youtube movies in your Form just add the following code for example:<br><strong>PrivateSub CommandButton1_Click()<br>WithMe.ShockwaveFlash1.LoadMovie0,&quot;http://www.youtube.com/v/jmHkMsrycBw&quot;<br>EndWith<br>EndSub</strong></blockquote><p></p>
<blockquote><strong>Good Work!</strong></blockquote><blockquote><strong>Do continue to add new Instructables!</strong></blockquote>
<p>There is problem in the previous code: Just all the code cannot be see.</p><p>I have corrected it.</p><p>PrivateSub CommandButton1_Click()</p><p>WithMe.ShockwaveFlash1 </p><p> .LoadMovie 0,&quot;http://www.youtube.com/v/jmHkMsrycBw&quot;</p><p>EndWith</p><p>EndSub</p><p>You can include other vedio by changing the link &quot;http://www.youtube.com/v/jmHkMsrycBw&quot; </p>
<p>I have tried the code. It works. Thank you sir.</p>
<p>Super work! </p>
<p>I thought it was complicated, your instructables made it simple. Thanks</p>
<p>Great work</p>
<p>The form is very beautiful. Good Job</p>
<p>Nice presentation</p>
<p>Is there ant way to automatically open the form?</p>
<p>@Sharone,</p><p>NIKHIL sir already added that in the step 4. See it. :)</p>
<p>Great instructable</p>
<p>Nice Job</p>
<p>Good work</p>
<p>I got inspired by your instructable .This is the first time I have tried to make a form in excel.</p>
<p>Great idea!</p>
<p>The new Form you have updated is really Great !</p><p>**********************************</p><blockquote> <em><strong>Its Awesome!</strong></em></blockquote><p><em><strong>**********************************</strong></em></p><p><em><strong>It will really a help in my survey project .</strong></em><br><em></em></p><p><em></em><br><em></em></p>
<p>Thank you!</p>
<p>When I run the code after opening the saved excel file , there is a message showing macros are disabled. What should I do. How to enable macro?</p>
<blockquote><strong><em>First</em></strong> Click the <b>Microsoft Office Button</b> , and then click <b>Excel Options</b>.<br><br>In the <b>Popular</b> category, under <b>Top options for working with Excel</b>, select the <b>Show Developer tab in the Ribbon</b> check box, and then click <b>OK</b>.</blockquote><ol><li><ol><li><p><strong> Note </strong> The Ribbon is a component of the Microsoft Office Fluent user interface.</p></ol><li>On the <strong>Developer</strong> tab, in the <strong>Code</strong> group, click <strong>Macro Security</strong>.<p> </p><li>Under <strong>Developer Macro Settings</strong>, select the <strong>Trust access to the VBA project object model</strong> check box.</ol><p>Then save and run it again it will work</p>
<p>Thank you sir.Thanks for your replay. I have done it. </p>
<p>&quot;My pleasure&quot; . Keep asking questions , if you have any confusions.</p>
<p>Gute Arbeit. :)</p><p>Ich will wissen , kann ich schlie&szlig;en vedio darin.</p>
<p>Gute Arbeit mean 'Great work' no?</p>
<p>I don't understand your language! </p>
<p>Please comment if you have any suggestions</p>
<p>Super Instructables. I like the method you have presented</p>
<p>Great job!</p>
<p>Thank you Vasutta...</p>
<p>Great inspiration to make bigger form.Thanks.</p>
<p>Thanks. Its so kind of you , and do making more Forms like this.</p>
<p>Easier than Visual studio :)</p>
<p>Ya it is easier than Visual studio.But it does not have as much tools as Visual studio. I am glad you made it.</p>
<p>Simple and easy to understand !</p>
<p>Thank you.</p>
<p>An old but easy and effective way to make gui.</p>
<p>If you don't have any other software available you can make use of Excel and make your own GUI. First try to make simple GUI and you will find it interesting , and you can make many other GUIs</p>

About This Instructable




More by NIKHILP3:Connect Relays Than the Pins Available in Arduino CONNECT  16384  RELAYS TO A SINGLE ARDUINO and Infinite other possibilities ATMOSPHERIC OXYGEN  AND  ITS INFLUENCE (Survive the Future) 
Add instructable to: