{"id":70,"date":"2018-10-30T15:22:00","date_gmt":"2018-10-30T15:22:00","guid":{"rendered":"http:\/\/www.vbastring.com\/blog\/?p=70"},"modified":"2020-11-23T22:21:48","modified_gmt":"2020-11-23T22:21:48","slug":"vba-trim","status":"publish","type":"post","link":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/","title":{"rendered":"VBA Trim"},"content":{"rendered":"<p><strong>This is a text and video example of how to write a VBA Trim function:<\/strong><\/p>\n<p>************************************************************************************* <\/p>\n<pre class=\"lang:vb decode:true \" >Public Sub GetLastName() \r\n\r\n      Dim strLastName As String \r\n\r\n      strLastName = Range(\"A2\") \r\n\r\n      strLastName = Right(strLastName, 8) \r\n\r\n'THE TRIM FUNCTION CLEANS THE VBA STRING VARIABLE OF \r\n'ANY LINGERING SPACES BOTH BEFORE AND AFTER...\r\n'IT MAKES \" Jack\" (WITH A SPACE IN THE BEGINNING)\r\n' LOOK LIKE \"Jack\" (NO SPACES). \r\n\r\n      strLastName = Trim(strLastName) \r\n\r\n      Range(\"C2\") = strLastName \r\n\r\nEnd Sub\t<\/pre>\n<p>*************************************************************************************<\/p>\n<p>Now watch how it&#8217;s done&#8230;<\/p>\n<p><iframe loading=\"lazy\" title=\"YouTube video player\" width=\"480\" height=\"390\" src=\"http:\/\/www.youtube.com\/embed\/izHABVueTiY\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>Let me know if you have any questions<\/p>\n<p>[simple_contact_form]\t<\/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 is a text and video example of how to write a VBA Trim function: ************************************************************************************* Public Sub GetLastName() Dim strLastName As String strLastName = Range(&#8220;A2&#8243;) strLastName = Right(strLastName, 8) &#8216;THE TRIM FUNCTION CLEANS THE VBA STRING VARIABLE OF &#8216;ANY LINGERING SPACES BOTH BEFORE AND AFTER&#8230; &#8216;IT MAKES &#8221; Jack&#8221; (WITH A SPACE IN 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-70","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 Trim - 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-trim\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VBA Trim - My Blog\" \/>\n<meta property=\"og:description\" content=\"This is a text and video example of how to write a VBA Trim function: ************************************************************************************* Public Sub GetLastName() Dim strLastName As String strLastName = Range(&quot;A2&quot;) strLastName = Right(strLastName, 8) &#039;THE TRIM FUNCTION CLEANS THE VBA STRING VARIABLE OF &#039;ANY LINGERING SPACES BOTH BEFORE AND AFTER... &#039;IT MAKES &quot; Jack&quot; (WITH A SPACE IN THE [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/\" \/>\n<meta property=\"og:site_name\" content=\"My Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-30T15:22:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-23T22:21:48+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<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-trim\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"headline\":\"VBA Trim\",\"datePublished\":\"2018-10-30T15:22:00+00:00\",\"dateModified\":\"2020-11-23T22:21:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/\"},\"wordCount\":34,\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/\",\"url\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/\",\"name\":\"VBA Trim - My Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#website\"},\"datePublished\":\"2018-10-30T15:22:00+00:00\",\"dateModified\":\"2020-11-23T22:21:48+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/#\\\/schema\\\/person\\\/e1de0b30e98940381697872449c341f5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/2018\\\/10\\\/30\\\/vba-trim\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vbastring.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VBA Trim\"}]},{\"@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 Trim - 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-trim\/","og_locale":"en_US","og_type":"article","og_title":"VBA Trim - My Blog","og_description":"This is a text and video example of how to write a VBA Trim function: ************************************************************************************* Public Sub GetLastName() Dim strLastName As String strLastName = Range(\"A2\") strLastName = Right(strLastName, 8) 'THE TRIM FUNCTION CLEANS THE VBA STRING VARIABLE OF 'ANY LINGERING SPACES BOTH BEFORE AND AFTER... 'IT MAKES \" Jack\" (WITH A SPACE IN THE [&hellip;]","og_url":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/","og_site_name":"My Blog","article_published_time":"2018-10-30T15:22:00+00:00","article_modified_time":"2020-11-23T22:21:48+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/#article","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/"},"author":{"name":"admin","@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"headline":"VBA Trim","datePublished":"2018-10-30T15:22:00+00:00","dateModified":"2020-11-23T22:21:48+00:00","mainEntityOfPage":{"@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/"},"wordCount":34,"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/","url":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/","name":"VBA Trim - My Blog","isPartOf":{"@id":"https:\/\/vbastring.com\/blog\/#website"},"datePublished":"2018-10-30T15:22:00+00:00","dateModified":"2020-11-23T22:21:48+00:00","author":{"@id":"https:\/\/vbastring.com\/blog\/#\/schema\/person\/e1de0b30e98940381697872449c341f5"},"breadcrumb":{"@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vbastring.com\/blog\/2018\/10\/30\/vba-trim\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vbastring.com\/blog\/"},{"@type":"ListItem","position":2,"name":"VBA Trim"}]},{"@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\/70","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=70"}],"version-history":[{"count":3,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":525,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions\/525"}],"wp:attachment":[{"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vbastring.com\/blog\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}