{"id":703,"date":"2019-06-20T03:47:25","date_gmt":"2019-06-20T03:47:25","guid":{"rendered":"http:\/\/www.vbastring.com\/blog\/?p=703"},"modified":"2020-11-23T20:49:06","modified_gmt":"2020-11-23T20:49:06","slug":"how-to-have-excel-vba-create-sheets-based-on-a-list","status":"publish","type":"post","link":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/","title":{"rendered":"How To Have Excel VBA Create Sheets Based On A List"},"content":{"rendered":"<p>This code with use VBA to create sheets based on a list of names.<\/p>\n<p>In the following image, we have a data sheet listing names in column B.  We want to create sheet names based<br \/>\non the names in that column.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.png?resize=238%2C300\" alt=\"\" width=\"238\" height=\"300\" class=\"aligncenter size-medium wp-image-704\" \/><\/a><\/p>\n<p><strong>Make sure your Excel spreadsheet is saved as an .xlsm and accepts macros.<\/strong><\/p>\n<p>In the VBE, add a new module and type the following:<\/p>\n<pre class=\"lang:vb decode:true \" >\r\n\r\n'loeblcomservices.com\r\n\r\nSub CreateSheets()\r\n    Dim rng As Range\r\n    Dim varTabName As Variant\r\n    '************************************************************\r\n    '1. Here is the range with the names to create sheet tabs for:\r\n    '************************************************************\r\n    \r\n    Set rng = Sheets(\"MASTER DATA ENTRY\").Range(\"B9:B11\")\r\n    \r\n    'loop each row\r\n    For Each varTabName In rng.Cells\r\n        \r\n        'create a sheet tab for the value\r\n        CreateTab (varTabName.Value)\r\n        \r\n    Next\r\n\r\n    Set rng = Nothing\r\n    \r\n    MsgBox \"Operation Complete\"\r\n    \r\nEnd Sub\r\n\r\n\r\nFunction CreateTab(TabName) As Boolean\r\n    Dim blnExists As Boolean\r\n    Dim strSheetName As String\r\n    \r\n    strSheetName = TabName\r\n    \r\n    'does sheet already exist?  If so, don't add it.\r\n    blnExists = SheetExists(strSheetName)\r\n    \r\n    'if it doesn't exist then create it\r\n    If blnExists = False Then\r\n        Sheets.Add(After:=Sheets(Sheets.Count)).Name = strSheetName\r\n    End If\r\nEnd Function\r\n\r\nFunction SheetExists(strSheet As String) As Boolean\r\n    SheetExists = Evaluate(\"ISREF('\" & strSheet & \"'!A1)\")\r\nEnd Function\r\n\r\n\r\n<\/pre>\n<p>When you press F5, and run the code, you&#8217;ll find the newly created sheets!<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets2.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets2-300x281.png?resize=300%2C281\" alt=\"\" width=\"300\" height=\"281\" class=\"aligncenter size-medium wp-image-709\" \/><\/a><\/p>\n<p>We could have done more than 3 but that&#8217;s a good example.<\/p>\n<p>Let me know if you have any questions.<\/p>\n<p>****************************************************<\/p>\n<table border=\"1\" width=\"100%\">\n<tr>\n<td align=\"middle\">\n<div class=\"AW-Form-1094354588\"><\/div>\n<p><script type=\"text\/javascript\">(function(d, s, id) {\n    var js, fjs = d.getElementsByTagName(s)[0];\n    if (d.getElementById(id)) return;\n    js = d.createElement(s); js.id = id;\n    js.src = \"\/\/forms.aweber.com\/form\/88\/1094354588.js\";\n    fjs.parentNode.insertBefore(js, fjs);\n    }(document, \"script\", \"aweber-wjs-kkrwj13ov\"));\n<\/script>\n<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>This code with use VBA to create sheets based on a list of names. In the following image, we have a data sheet listing names in column B. We want to create sheet names based on the names in that column. Make sure your Excel spreadsheet is saved as an .xlsm and accepts macros. In [&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-703","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Have Excel VBA Create Sheets Based On A List - 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\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Have Excel VBA Create Sheets Based On A List - My Blog\" \/>\n<meta property=\"og:description\" content=\"This code with use VBA to create sheets based on a list of names. In the following image, we have a data sheet listing names in column B. We want to create sheet names based on the names in that column. Make sure your Excel spreadsheet is saved as an .xlsm and accepts macros. In [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/\" \/>\n<meta property=\"og:site_name\" content=\"My Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-20T03:47:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-23T20:49:06+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.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\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"headline\":\"How To Have Excel VBA Create Sheets Based On A List\",\"datePublished\":\"2019-06-20T03:47:25+00:00\",\"dateModified\":\"2020-11-23T20:49:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/\"},\"wordCount\":111,\"image\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/create_sheets1-238x300.png\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/\",\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/\",\"name\":\"How To Have Excel VBA Create Sheets Based On A List - My Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/create_sheets1-238x300.png\",\"datePublished\":\"2019-06-20T03:47:25+00:00\",\"dateModified\":\"2020-11-23T20:49:06+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/create_sheets1-238x300.png\",\"contentUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/create_sheets1-238x300.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/06\\\/20\\\/how-to-have-excel-vba-create-sheets-based-on-a-list\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Have Excel VBA Create Sheets Based On A List\"}]},{\"@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":"How To Have Excel VBA Create Sheets Based On A List - 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\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/","og_locale":"en_US","og_type":"article","og_title":"How To Have Excel VBA Create Sheets Based On A List - My Blog","og_description":"This code with use VBA to create sheets based on a list of names. In the following image, we have a data sheet listing names in column B. We want to create sheet names based on the names in that column. Make sure your Excel spreadsheet is saved as an .xlsm and accepts macros. In [&hellip;]","og_url":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/","og_site_name":"My Blog","article_published_time":"2019-06-20T03:47:25+00:00","article_modified_time":"2020-11-23T20:49:06+00:00","og_image":[{"url":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.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\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#article","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/"},"author":{"name":"admin","@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"headline":"How To Have Excel VBA Create Sheets Based On A List","datePublished":"2019-06-20T03:47:25+00:00","dateModified":"2020-11-23T20:49:06+00:00","mainEntityOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/"},"wordCount":111,"image":{"@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#primaryimage"},"thumbnailUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.png","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/","url":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/","name":"How To Have Excel VBA Create Sheets Based On A List - My Blog","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#primaryimage"},"image":{"@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#primaryimage"},"thumbnailUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.png","datePublished":"2019-06-20T03:47:25+00:00","dateModified":"2020-11-23T20:49:06+00:00","author":{"@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"breadcrumb":{"@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#primaryimage","url":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.png","contentUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/06\/create_sheets1-238x300.png"},{"@type":"BreadcrumbList","@id":"https:\/\/vbastring.com\/blog\/2019\/06\/20\/how-to-have-excel-vba-create-sheets-based-on-a-list\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vbastring.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Have Excel VBA Create Sheets Based On A List"}]},{"@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\/703","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=703"}],"version-history":[{"count":5,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/703\/revisions"}],"predecessor-version":[{"id":715,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/703\/revisions\/715"}],"wp:attachment":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/media?parent=703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/categories?post=703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/tags?post=703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}