Google search

Basic and advanced computer skills like Excel with macros, How to speed up your PC, C, CPP, Java programming, HTML, JavaScript, PHP, Wordpress, all web tools, Android tutorials, MySQL Tutorials, WAMP server installation. etc.

Creating an Excel form with Macros

This tutorial teaches you how to create an excel forms with Macros with step-by-step approaches. 

Step1 :  Open MS Excel Application and then click on “Developer” Tab  then click on “Visual Basic” option as shown in following screen shots. 












Step2: Click on “Insert” menu then select “UserForm” as shown in below image












Step3: Drag and drop the controls on the form (in this example:  3 Labels, 3 Text Boxes and 2 Buttons and set properties for Label1 to “Enter Product Name”, Label2 to “Enter Qty”, Label3 to “Enter Product Price”, Button1 to “AddNew Record” and Button2 to “Reset” in “Caption” under properties dialog box) follow below image.



















Step4: Now, Double click on “AddNew Record” button to write some code for inserting records to current sheet. Follow below screen image



Step 5: Now, test the form by running it, click on Green Forward arrow symbol or by pressing function key “F5” (see below image)






Step 6: You’ll see following output after pressing F5 or clicking on green forward arrow






















Step 7: Enter a record as following and hit the “AddNew Record” Button. After this, one record is added to the sheet (sheet10 in this example)

















Step8: Now close the form by clicking on “X” it will take you to the design mode. And enter some code for “Reset” button for resetting all values. Follow below image. [double click on “Reset” button and add following code]








Step9:  To call the User Form, which is created now, insert a button in the current sheet. [go to “Developer” tab and click -> Insert -> Command Button, drag on the sheet.   Follow below image.














Step 10: Right click on “ User Form” button and select “View Code”











Step 11: Enter following a line of code in it. Follow below image.









Step12: Now Click back on “Design Mode” to enable “User Form” button functioning, Click on “User Form” button and you’ll see following screen. [now start entering list of records] 

















Step 13: Enter few more record by clicking on “AddNew Record” button and “Reset” for clearing all values.












That’s all for now! I’m coming with new Macro example in next blog.

No comments:

Post a Comment