{"id":279,"date":"2019-01-11T19:00:17","date_gmt":"2019-01-11T19:00:17","guid":{"rendered":"http:\/\/www.vbastring.com\/blog\/?p=279"},"modified":"2019-01-11T19:00:17","modified_gmt":"2019-01-11T19:00:17","slug":"what-is-a-userform-in-vba","status":"publish","type":"post","link":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/","title":{"rendered":"What is a UserForm in VBA?"},"content":{"rendered":"<p>A UserForm is a tool for entering data into your worksheet in a controlled manner.<\/p>\n<p>You can control what cells the user enters the data in, and the type of data that gets entered into the cells.<\/p>\n<p>You can also validate the data entered on the form before it actually gets entered into the worksheet.<\/p>\n<p>A UserForm serves as a buffer layer between the user and the worksheet.<\/p>\n<p>You can have a UserForm appear as soon as the workbook is opened, so the user has to immediately interact with it.<\/p>\n<p>In the following example, the UserForm appears whenever the worksheet is activated:<\/p>\n<pre class=\"lang:vb decode:true \" >Private Sub Worksheet_Activate()\r\n    UserForm1.Show\r\nEnd Sub\r\n\r\n<\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png?resize=367%2C274\" alt=\"\" width=\"367\" height=\"274\" class=\"alignleft size-full wp-image-283\" \/><\/a><\/p>\n<p>&#8230;and here we are entering so simple information into it:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm2.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm2.png?resize=473%2C360\" alt=\"\" width=\"473\" height=\"360\" class=\"alignleft size-full wp-image-284\" \/><\/a><\/p>\n<pre class=\"lang:vb decode:true \" >Private Sub btnOK_Click()\r\n    Range(\"A2\").Value = Me.txtFirstName\r\n    Range(\"B2\").Value = Me.txtLastName\r\nEnd Sub\r\n<\/pre>\n<p>Let me know if you have any questions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A UserForm is a tool for entering data into your worksheet in a controlled manner. You can control what cells the user enters the data in, and the type of data that gets entered into the cells. You can also validate the data entered on the form before it actually gets entered into the worksheet. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-279","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is a UserForm in VBA? - My Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is a UserForm in VBA? - My Blog\" \/>\n<meta property=\"og:description\" content=\"A UserForm is a tool for entering data into your worksheet in a controlled manner. You can control what cells the user enters the data in, and the type of data that gets entered into the cells. You can also validate the data entered on the form before it actually gets entered into the worksheet. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/\" \/>\n<meta property=\"og:site_name\" content=\"My Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-11T19:00:17+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"headline\":\"What is a UserForm in VBA?\",\"datePublished\":\"2019-01-11T19:00:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/\"},\"wordCount\":126,\"image\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/VBA-UserForm.png\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/\",\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/\",\"name\":\"What is a UserForm in VBA? - My Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/VBA-UserForm.png\",\"datePublished\":\"2019-01-11T19:00:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/VBA-UserForm.png\",\"contentUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/VBA-UserForm.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/01\\\/11\\\/what-is-a-userform-in-vba\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is a UserForm in VBA?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/\",\"name\":\"My Blog\",\"description\":\"My WordPress Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b2feaa698a4bd91b409df1beb5ff6acc2d7842d4f78543d413ebd468bc0171af?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b2feaa698a4bd91b409df1beb5ff6acc2d7842d4f78543d413ebd468bc0171af?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b2feaa698a4bd91b409df1beb5ff6acc2d7842d4f78543d413ebd468bc0171af?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/vbastring.com\\\/blog\"],\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is a UserForm in VBA? - My Blog","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:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/","og_locale":"en_US","og_type":"article","og_title":"What is a UserForm in VBA? - My Blog","og_description":"A UserForm is a tool for entering data into your worksheet in a controlled manner. You can control what cells the user enters the data in, and the type of data that gets entered into the cells. You can also validate the data entered on the form before it actually gets entered into the worksheet. [&hellip;]","og_url":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/","og_site_name":"My Blog","article_published_time":"2019-01-11T19:00:17+00:00","og_image":[{"url":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png","type":"","width":"","height":""}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#article","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/"},"author":{"name":"admin","@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"headline":"What is a UserForm in VBA?","datePublished":"2019-01-11T19:00:17+00:00","mainEntityOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/"},"wordCount":126,"image":{"@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#primaryimage"},"thumbnailUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/","url":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/","name":"What is a UserForm in VBA? - My Blog","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#primaryimage"},"image":{"@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#primaryimage"},"thumbnailUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png","datePublished":"2019-01-11T19:00:17+00:00","author":{"@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"breadcrumb":{"@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#primaryimage","url":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png","contentUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/01\/VBA-UserForm.png"},{"@type":"BreadcrumbList","@id":"https:\/\/vbastring.com\/blog\/2019\/01\/11\/what-is-a-userform-in-vba\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vbastring.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What is a UserForm in VBA?"}]},{"@type":"WebSite","@id":"https:\/\/vbastring.com\/blog\/#website","url":"https:\/\/vbastring.com\/blog\/","name":"My Blog","description":"My WordPress Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vbastring.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b2feaa698a4bd91b409df1beb5ff6acc2d7842d4f78543d413ebd468bc0171af?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b2feaa698a4bd91b409df1beb5ff6acc2d7842d4f78543d413ebd468bc0171af?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b2feaa698a4bd91b409df1beb5ff6acc2d7842d4f78543d413ebd468bc0171af?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/vbastring.com\/blog"],"url":"https:\/\/vbastring.com\/blog\/author\/admin\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":4,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"predecessor-version":[{"id":289,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/279\/revisions\/289"}],"wp:attachment":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}