{"id":685,"date":"2019-05-31T23:08:10","date_gmt":"2019-05-31T23:08:10","guid":{"rendered":"http:\/\/www.vbastring.com\/blog\/?p=685"},"modified":"2019-05-31T23:28:07","modified_gmt":"2019-05-31T23:28:07","slug":"how-to-use-the-vba-trim-and-split-functions-to-parse-names","status":"publish","type":"post","link":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/","title":{"rendered":"How To Use The VBA Trim And Split Functions To Parse Names"},"content":{"rendered":"<p>In column A we have a list of random names<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png?resize=300%2C108\" alt=\"\" width=\"300\" height=\"108\" class=\"aligncenter size-medium wp-image-695\" \/><\/a><\/p>\n<p>Our task is to divide the list of names into first and last names<\/p>\n<p>We are going to parse (divide) the names by using the VBA &#8220;split&#8221; function.  Then we will use the VBA Trim function to remove the excess spaces.<\/p>\n<p>We will use a custom vba function to facilitate this task:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func2.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func2-300x103.png?resize=300%2C103\" alt=\"\" width=\"300\" height=\"103\" class=\"aligncenter size-medium wp-image-696\" \/><\/a><\/p>\n<p><strong>Remember that customized functions need to be placed in modules!<\/strong><\/p>\n<p> <a href=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func-300x188.png?resize=300%2C188\" alt=\"\" width=\"300\" height=\"188\" class=\"aligncenter size-medium wp-image-688\" \/><\/a><\/p>\n<pre class=\"lang:vb decode:true \" >Function GetFName(WholeName) As String\r\n    Dim strTemp As String\r\n    Dim varParts As Variant\r\n        \r\n    varParts = Split(WholeName, \" \")\r\n    \r\n    strTemp = varParts(0)\r\n    \r\n    strTemp = Trim(strTemp)\r\n\r\n    GetFName = strTemp\r\n    \r\nEnd Function\r\n\r\n\r\nFunction GetLName(WholeName) As String\r\n    Dim strTemp As String\r\n    Dim varParts As Variant\r\n    \r\n    varParts = Split(WholeName, \" \")\r\n    \r\n    strTemp = varParts(1)\r\n    strTemp = Trim(strTemp)\r\n    \r\n    GetLName = strTemp\r\n    \r\nEnd Function\r\n<\/pre>\n<p>Now watch how it&#8217;s done:<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/0xaqRxeGLGI\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/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<p><center><br \/>\n<a href=\"http:\/\/www.getyourboomback.com\/products\/amino-boosters#_l_2pn\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/leaddyno-client-images.s3.amazonaws.com\/cffa678c5db61bb2476a50e2198c69454765190c\/79c8cd6d7bcc3fb81771441a1a1aa70677e2c8b5_GYBB-580x394-boosters-01.jpg?ssl=1\" \/><\/a><\/center>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In column A we have a list of random names Our task is to divide the list of names into first and last names We are going to parse (divide) the names by using the VBA &#8220;split&#8221; function. Then we will use the VBA Trim function to remove the excess spaces. We will use a [&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-685","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>How To Use The VBA Trim And Split Functions To Parse Names - 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\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Use The VBA Trim And Split Functions To Parse Names - My Blog\" \/>\n<meta property=\"og:description\" content=\"In column A we have a list of random names Our task is to divide the list of names into first and last names We are going to parse (divide) the names by using the VBA &#8220;split&#8221; function. Then we will use the VBA Trim function to remove the excess spaces. We will use a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/\" \/>\n<meta property=\"og:site_name\" content=\"My Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-31T23:08:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-31T23:28:07+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.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\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"headline\":\"How To Use The VBA Trim And Split Functions To Parse Names\",\"datePublished\":\"2019-05-31T23:08:10+00:00\",\"dateModified\":\"2019-05-31T23:28:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/\"},\"wordCount\":99,\"image\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/\",\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/\",\"name\":\"How To Use The VBA Trim And Split Functions To Parse Names - My Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png\",\"datePublished\":\"2019-05-31T23:08:10+00:00\",\"dateModified\":\"2019-05-31T23:28:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png\",\"contentUrl\":\"http:\\\/\\\/www.vbastring.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2019\\\/05\\\/31\\\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Use The VBA Trim And Split Functions To Parse Names\"}]},{\"@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 Use The VBA Trim And Split Functions To Parse Names - 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\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/","og_locale":"en_US","og_type":"article","og_title":"How To Use The VBA Trim And Split Functions To Parse Names - My Blog","og_description":"In column A we have a list of random names Our task is to divide the list of names into first and last names We are going to parse (divide) the names by using the VBA &#8220;split&#8221; function. Then we will use the VBA Trim function to remove the excess spaces. We will use a [&hellip;]","og_url":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/","og_site_name":"My Blog","article_published_time":"2019-05-31T23:08:10+00:00","article_modified_time":"2019-05-31T23:28:07+00:00","og_image":[{"url":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.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\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#article","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/"},"author":{"name":"admin","@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"headline":"How To Use The VBA Trim And Split Functions To Parse Names","datePublished":"2019-05-31T23:08:10+00:00","dateModified":"2019-05-31T23:28:07+00:00","mainEntityOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/"},"wordCount":99,"image":{"@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#primaryimage"},"thumbnailUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/","url":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/","name":"How To Use The VBA Trim And Split Functions To Parse Names - My Blog","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#primaryimage"},"image":{"@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#primaryimage"},"thumbnailUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png","datePublished":"2019-05-31T23:08:10+00:00","dateModified":"2019-05-31T23:28:07+00:00","author":{"@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"breadcrumb":{"@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#primaryimage","url":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png","contentUrl":"http:\/\/www.vbastring.com\/blog\/wp-content\/uploads\/2019\/05\/How-To-Use-The-VBA-Trim-And-Split-Func1-300x108.png"},{"@type":"BreadcrumbList","@id":"https:\/\/vbastring.com\/blog\/2019\/05\/31\/how-to-use-the-vba-trim-and-split-functions-to-parse-names\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vbastring.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Use The VBA Trim And Split Functions To Parse Names"}]},{"@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\/685","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=685"}],"version-history":[{"count":5,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/685\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/685\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/media?parent=685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/categories?post=685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/tags?post=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}