{"id":80,"date":"2018-10-30T15:46:12","date_gmt":"2018-10-30T15:46:12","guid":{"rendered":"http:\/\/www.vbastring.com\/blog\/?p=80"},"modified":"2018-10-30T15:46:12","modified_gmt":"2018-10-30T15:46:12","slug":"vba-listbox","status":"publish","type":"post","link":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/","title":{"rendered":"VBA Listbox"},"content":{"rendered":"<p>This is a text and video example of how to implement a VBA Listbox:<\/p>\n<p>On your Excel worksheet show your &#8220;Forms Toolbar&#8221;. In Excel 2003 and prior, right click the standard toolbar (at the top of your screen) and choose &#8220;Forms Toolbar&#8221;. In Excel 2007 and above click the round Microsoft Office Button at the top left or your screen. Then choose &#8220;Excel Options&#8221; at the bottom of the list. The choose &#8220;Popular&#8221; and select the &#8220;Show Developer tab&#8230;&#8221; and select to show the developer tab.<\/p>\n<p>Add list box to your worksheet, then choose to show the properties. When you right click the listbox control, choose &#8220;Properties&#8221; and &#8220;Control&#8221;, then key in &#8220;A1&#8221; for the cell link. Call one of your worksheets &#8220;data&#8221;, and for &#8220;InputRange&#8221; enter &#8220;data!A1:A5&#8221; (that&#8217;s the naming structure [worksheet name]![cell range]). Make sure you enter some values into the sheet called &#8220;data&#8221; and cells &#8220;A1-A5&#8221; or else you won&#8217;t show anything in your new combobox.<br \/>\nThis is what your worksheet should look like:<br \/>\nCell A1 = &#8220;red&#8221;<br \/>\nCell A2 = &#8220;blue&#8221;<br \/>\nCell A3 = &#8220;yellow&#8221;<br \/>\nCell A4 = &#8220;green&#8221;<br \/>\nCell A5 = &#8220;brown&#8221;<br \/>\nIt&#8217;s going to look like this, and you&#8217;ll have to apply the principles to your situation:<br \/>\n************************************************<br \/>\nFor the single selection option<\/p>\n<pre class=\"lang:vb decode:true \" >Private Sub SelectSingleValue()\r\n\r\n   Dim intCount As Integer\r\n   Dim strTemp As String\r\n\r\n   strTemp = lstColors.Value\r\n   Range(\"A1\") = strTemp\r\n\r\nEnd Sub\r\n<\/pre>\n<p>***********************************************<br \/>\n***********************************************<br \/>\nFor the multiple selection option<\/p>\n<pre class=\"lang:vb decode:true \" >Private Sub SelectMultiValues()\r\n\r\n   Dim intCount As Integer\r\n   Dim strTemp As String\r\n   Dim lngCellCount As Integer\r\n\r\n   lngCellCount = 1\r\n\r\n   For intCount = 0 To lstColors.ListCount - 1\r\n      If lstColors.Selected(intCount) = True Then\r\n         strTemp = lstColors.List(intCount)\r\n         Range(\"A\" &amp; lngCellCount) = strTemp\r\n\r\n         lngCellCount = lngCellCount + 1\r\n      End If\r\n   Next\r\n\r\nEnd Sub<\/pre>\n<p>*********************************************************<br \/>\nNow watch how it&#8217;s done (both the single and multiple select)&#8230;<\/p>\n<p><iframe loading=\"lazy\" title=\"YouTube video player\" width=\"480\" height=\"390\" src=\"http:\/\/www.youtube.com\/embed\/oFLg9LXqCvs\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>Let me know if you have any questions<\/p>\n<p>[simple_contact_form]\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a text and video example of how to implement a VBA Listbox: On your Excel worksheet show your &#8220;Forms Toolbar&#8221;. In Excel 2003 and prior, right click the standard toolbar (at the top of your screen) and choose &#8220;Forms Toolbar&#8221;. In Excel 2007 and above click the round Microsoft Office Button at the [&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-80","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>VBA Listbox - 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\/2018\/10\/30\/vba-listbox\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VBA Listbox - My Blog\" \/>\n<meta property=\"og:description\" content=\"This is a text and video example of how to implement a VBA Listbox: On your Excel worksheet show your &#8220;Forms Toolbar&#8221;. In Excel 2003 and prior, right click the standard toolbar (at the top of your screen) and choose &#8220;Forms Toolbar&#8221;. In Excel 2007 and above click the round Microsoft Office Button at the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/\" \/>\n<meta property=\"og:site_name\" content=\"My Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-30T15:46:12+00:00\" \/>\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\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"headline\":\"VBA Listbox\",\"datePublished\":\"2018-10-30T15:46:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/\"},\"wordCount\":239,\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/\",\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/\",\"name\":\"VBA Listbox - My Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#website\"},\"datePublished\":\"2018-10-30T15:46:12+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-listbox\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VBA Listbox\"}]},{\"@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":"VBA Listbox - 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\/2018\/10\/30\/vba-listbox\/","og_locale":"en_US","og_type":"article","og_title":"VBA Listbox - My Blog","og_description":"This is a text and video example of how to implement a VBA Listbox: On your Excel worksheet show your &#8220;Forms Toolbar&#8221;. In Excel 2003 and prior, right click the standard toolbar (at the top of your screen) and choose &#8220;Forms Toolbar&#8221;. In Excel 2007 and above click the round Microsoft Office Button at the [&hellip;]","og_url":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/","og_site_name":"My Blog","article_published_time":"2018-10-30T15:46:12+00:00","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\/2018\/10\/30\/vba-listbox\/#article","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/"},"author":{"name":"admin","@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"headline":"VBA Listbox","datePublished":"2018-10-30T15:46:12+00:00","mainEntityOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/"},"wordCount":239,"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/","url":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/","name":"VBA Listbox - My Blog","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/#website"},"datePublished":"2018-10-30T15:46:12+00:00","author":{"@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"breadcrumb":{"@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-listbox\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vbastring.com\/blog\/"},{"@type":"ListItem","position":2,"name":"VBA Listbox"}]},{"@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\/80","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=80"}],"version-history":[{"count":1,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/80\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}