{"id":1287,"date":"2013-12-11T07:06:52","date_gmt":"2013-12-11T07:06:52","guid":{"rendered":"http:\/\/excelvbatutor.com\/?page_id=1287"},"modified":"2019-04-19T08:22:38","modified_gmt":"2019-04-19T08:22:38","slug":"excel-vbaa-2010-lesson-15-userform","status":"publish","type":"page","link":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/","title":{"rendered":"Excel 2010 VBA Lesson 15: The UserForm"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">&nbsp;<strong><a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-14-errors-handling\/\">[Lesson 14]<\/a>&lt;&lt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-tutorial\/\">[Table of Contents]<\/a>&gt;&gt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-16-introduction-to-excel-vba-2010-object-part-1\/\">[Lesson 16]<\/a><\/strong><\/h4>\n\n\n\n<p>In a previous lesson, you have learned how to use the message box.&nbsp;In this lesson, you will learn how to create a dialog box using the UserForm in Excel 2010 &nbsp;VBA macro programming.<\/p>\n\n\n\n<script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>The UserForm let you create a &nbsp;dialog that allows the user to view data from the spreadsheet as well as perform some operations such as saving, printing, searching and more. To use the UserForm in the Excel 2010 VBA &nbsp;editor, select Insert then choose UserForm from the drop-down menu, as shown in Figure 15.1<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"570\" height=\"309\" src=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg\" alt=\"vba2010_figure 15.1\" class=\"wp-image-1292\"\/><\/a><\/figure><\/div>\n\n\n\n<p><script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br>\n<script><br \/>\n     (adsbygoogle = window.adsbygoogle || []).push({});<br \/>\n<\/script><br>\n<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Figure 15.1<\/h4>\n\n\n\n<p>The UserForm is a blank form that you can place controls on it. It is accompanied by a Toolbox window that allows you to select controls to place on the form. The Toolbox comprises controls such as text boxes, check boxes, command buttons, list boxes and more, as shown below:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_fig15.2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"740\" height=\"546\" src=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_fig15.2.jpg\" alt=\"vba2010_fig15.2\" class=\"wp-image-1294\"\/><\/a><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Figure 15.2<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">Example 15.1<\/h4>\n\n\n\n<p>You can display information from the spreadsheet in a list box. If you wish to display information in column 1 and column 2 with headings from the spreadsheet, you need to set the following properties of the list box:\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ColumnCount=2\nColumnHeads=True\nRowSource=Sheet1!a2:b5\n<\/pre>\n\n\n\n<p><script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br>\n<script><br \/>\n     (adsbygoogle = window.adsbygoogle || []).push({});<br \/>\n<\/script><br>\n* If you are using Excel 2016, you have to use ListFillRange instead of RowSource.<br>\nPress F5 to run the program and you can see the following output interface:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_fig15.3.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"525\" src=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_fig15.3.jpg\" alt=\"vba2010_fig15.3\" class=\"wp-image-1311\"\/><\/a><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Figure 15.3<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">Example 15.2<\/h4>\n\n\n\n<p>You can create a simple calculator to perform a simple calculation involving the information on a spreadsheet.<\/p>\n\n\n\n<p>Insert a Userform, then place two text boxes, one label control, and a command button onto the form. Set the ControlSource property of the first text box to sheet1!a1 and the ControlSource property of the second text box to sheet1!b1. Add three more labels, place the first label besides text box 1 and change the caption to number 1 and place the second label besides text box 2 and change the caption to number 2, and place the last label besides the label that you will display the sum of the two numbers in the text boxes and change to caption to Total. Lastly, change the caption of the command button to Calculate.<\/p>\n\n\n\n<p>Now click on the command button and enter the following code:\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Private Sub CommandButton1_Click()\n Label1.Caption = Val(TextBox1.Text) + Val(TextBox2.Text)\n Cells(1, 3).Value = Label1.Caption\nEnd Sub\n<\/pre>\n\n\n\n<p>Press F5 to run the program and you will be presented the interface of a simple calculator. Click on the calculate button and you will obtain the sum of the two numbers from cells a1 and cells b1 and the total are shown on the calculator as well as in cells c3.<\/p>\n\n\n\n<p>The output interface is shown in Figure 15.4<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_fig15.4.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"540\" src=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_fig15.4.jpg\" alt=\"vba2010_fig15.4\" class=\"wp-image-1317\"\/><\/a><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Figure 15.4<\/h4>\n\n\n\n<p><script async=\"\" src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br>\n<script><br \/>\n     (adsbygoogle = window.adsbygoogle || []).push({});<br \/>\n<\/script><br>\n<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">&nbsp;<strong><a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-14-errors-handling\/\">[Lesson 14]<\/a>&lt;&lt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-tutorial\/\">[Table of Contents]<\/a>&gt;&gt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-16-introduction-to-excel-vba-2010-object-part-1\/\">[Lesson 16]<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;[Lesson 14]&lt;&lt;[Table of Contents]&gt;&gt;[Lesson 16] In a previous lesson, you have learned how to use the message box.&nbsp;In this lesson, you will learn how to create a dialog box using the UserForm in Excel 2010 &nbsp;VBA macro programming. The UserForm let you create a &nbsp;dialog that allows the user to view data from the spreadsheet &hellip; <a href=\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Excel 2010 VBA Lesson 15: The UserForm&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5012,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-1287","page","type-page","status-publish","hentry","category-buttons-and-boxes"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Excel 2010 VBA Lesson 15: The UserForm - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor<\/title>\n<meta name=\"description\" content=\"This lesson illustrates the use of UserForm in excel 2010 VBA\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel 2010 VBA Lesson 15: The UserForm - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\" \/>\n<meta property=\"og:description\" content=\"This lesson illustrates the use of UserForm in excel 2010 VBA\" \/>\n<meta property=\"og:url\" content=\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-19T08:22:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"570\" \/>\n\t<meta property=\"og:image:height\" content=\"309\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/\",\"url\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/\",\"name\":\"Excel 2010 VBA Lesson 15: The UserForm - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\",\"isPartOf\":{\"@id\":\"https:\/\/excelvbatutor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg\",\"datePublished\":\"2013-12-11T07:06:52+00:00\",\"dateModified\":\"2019-04-19T08:22:38+00:00\",\"description\":\"This lesson illustrates the use of UserForm in excel 2010 VBA\",\"breadcrumb\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#primaryimage\",\"url\":\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg\",\"contentUrl\":\"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg\",\"width\":570,\"height\":309},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/excelvbatutor.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel 2010 VBA Lesson 15: The UserForm\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/excelvbatutor.com\/#website\",\"url\":\"https:\/\/excelvbatutor.com\/\",\"name\":\"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\",\"description\":\"Master Excel VBA with free tutorials, examples, and personalized guidance. Perfect for beginners and advanced users looking to automate Excel.\",\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Excel 2010 VBA Lesson 15: The UserForm - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","description":"This lesson illustrates the use of UserForm in excel 2010 VBA","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/","og_locale":"en_US","og_type":"article","og_title":"Excel 2010 VBA Lesson 15: The UserForm - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","og_description":"This lesson illustrates the use of UserForm in excel 2010 VBA","og_url":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/","og_site_name":"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","article_modified_time":"2019-04-19T08:22:38+00:00","og_image":[{"width":570,"height":309,"url":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg","type":"image\/jpeg"}],"twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/","url":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/","name":"Excel 2010 VBA Lesson 15: The UserForm - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","isPartOf":{"@id":"https:\/\/excelvbatutor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#primaryimage"},"image":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#primaryimage"},"thumbnailUrl":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg","datePublished":"2013-12-11T07:06:52+00:00","dateModified":"2019-04-19T08:22:38+00:00","description":"This lesson illustrates the use of UserForm in excel 2010 VBA","breadcrumb":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#primaryimage","url":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg","contentUrl":"https:\/\/excelvbatutor.com\/wp-content\/uploads\/2013\/12\/vba2010_figure-15.1.jpg","width":570,"height":309},{"@type":"BreadcrumbList","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vbaa-2010-lesson-15-userform\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/excelvbatutor.com\/"},{"@type":"ListItem","position":2,"name":"Excel 2010 VBA Lesson 15: The UserForm"}]},{"@type":"WebSite","@id":"https:\/\/excelvbatutor.com\/#website","url":"https:\/\/excelvbatutor.com\/","name":"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","description":"Master Excel VBA with free tutorials, examples, and personalized guidance. Perfect for beginners and advanced users looking to automate Excel.","inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/users\/5012"}],"replies":[{"embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1287"}],"version-history":[{"count":65,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1287\/revisions"}],"predecessor-version":[{"id":3325,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1287\/revisions\/3325"}],"wp:attachment":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}