{"id":4896,"date":"2016-11-08T16:15:00","date_gmt":"2016-11-08T15:15:00","guid":{"rendered":"https:\/\/www.myexcelonline.com\/?p=4896"},"modified":"2024-04-05T23:11:51","modified_gmt":"2024-04-05T21:11:51","slug":"extract-last-name-with-excels-replace-formula","status":"publish","type":"post","link":"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/","title":{"rendered":"Extract Last Name with Excel\u2019s REPLACE Formula"},"content":{"rendered":"<p><em><strong>What does it do?<\/strong><\/em><\/p>\n<p>Replaces part of a text string, based on the number of characters you specify, <a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-text-with-substring\/\" target=\"_blank\" rel=\"noopener\">with a different text string<\/a><\/p>\n<p><em><strong>Formula breakdown:<\/strong><\/em><\/p>\n<p>=REPLACE(<span style=\"color: #ff0000\"><span style=\"color: #339966\"><span style=\"color: #0000ff\">old_text, <span style=\"color: #ff0000\">start_num<\/span>, <span style=\"color: #339966\">num_chars<\/span>,<span style=\"color: #ff6600\"> new_text<\/span><\/span><\/span><\/span>)<\/p>\n<p><em><strong>What it means:<\/strong><\/em><\/p>\n<p>=REPLACE(<span style=\"color: #0000ff\">this cell<\/span><span style=\"color: #ff0000\"><span style=\"color: #339966\"><span style=\"color: #0000ff\">, <span style=\"color: #ff0000\">starting from this number<\/span>, <span style=\"color: #339966\">all the way to this number<\/span>,<span style=\"color: #ff6600\"> with this new text<\/span><\/span><\/span><\/span>)<\/p>\n<hr \/>\n<p>I had a scenario where I wanted to extract the last names from a list of names using a formula.<\/p>\n<p>Did you know that we can creatively use the\u00a0<strong>Replace formula\u00a0<\/strong>to replace the first name with an empty string, leaving us with the SURNAME?<\/p>\n<p>Here is what we want to happen:<\/p>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4904\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"513\" height=\"237\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06.png 513w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06-300x139.png 300w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>I explain how you can do this and please\u00a0go to the bottom of the page to see the animated gif tutorial:<\/p>\n<div class=\"after-post-box\">\n<p><iframe src=\"https:\/\/www.youtube.com\/embed\/vzWtLcKTlNk?rel=0 \" width=\"800\" height=\"400\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"width: 0px;overflow: hidden;line-height: 0\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><a href=\"https:\/\/www.youtube.com\/c\/MyExcelOnlinecomtutorials?sub_confirmation=1\" target=\"_blank\" rel=\"noopener noreferrer nofollow\"><img loading=\"lazy\" decoding=\"async\" class=\"alignmiddle wp-image-111468 size-full\" style=\"vertical-align: middle\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/1.yt_.png\" alt=\"\" title=\"\"><\/a><\/p>\n<p class=\"line-two\"><a class=\"IRPP_minimalist icon-download button small\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-.xlsx\" target=\"_blank\" rel=\"noopener noreferrer\" data-leadbox=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-.xlsx\" data-leadbox-id=\"147284833f72a2:12f08263ab46dc\"><span class=\"ctaText px-3 text-capitalize\"> download excel workbook <i class=\"fa fa-download\"><\/i><\/span><span class=\"postTitle px-3\">Replace-Extract-Last-Name-.xlsx<\/span><\/a><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000\"><strong>STEP 1:<\/strong>\u00a0<\/span>To start off, let us try the <strong>Search function<\/strong> and see what it will give us. We want to search on which character the space resides on. \u00a0 Type in:<\/p>\n<h2 style=\"text-align: center\"><span style=\"color: #0000ff\">=SEARCH(&#8221; &#8220;, C11)<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-00.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4898\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-00.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"477\" height=\"206\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-00.png 477w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-00-300x130.png 300w\" sizes=\"(max-width: 477px) 100vw, 477px\" \/><\/a><\/p>\n<p>You will see that it returned\u00a0<strong>6<\/strong>.<\/p>\n<p>This means our space is on the 6th character of the name <em><strong>Talon Ferguso<\/strong><strong>n<\/strong><\/em>.<\/p>\n<p>We will use this in our\u00a0<strong>Replace function<\/strong> later in <strong>STEP 3<\/strong>.<\/p>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-01.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4899\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-01.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"480\" height=\"212\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-01.png 480w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-01-300x133.png 300w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000\"><strong>STEP 2:<\/strong> <\/span>Clear the Search function.\u00a0We need to <strong>enter the <i>Replace\u00a0<\/i>function <\/strong>next to the cell that we want to\u00a0clean\u00a0the data from:<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_57_1 counter-flat ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li><a href=\"#\" class=\"scroll-to-download\">Free Practice Workbook<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/#REPLACE\" title=\"=REPLACE\">=REPLACE<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/#old_text\" title=\"old_text\">old_text<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/#start_num\" title=\"start_num\">start_num<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/#i\" title=\"\u00a0\">\u00a0<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/#num_chars\" title=\"num_chars\">num_chars<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/extract-last-name-with-excels-replace-formula\/#new_text\" title=\"new_text\">new_text<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center\"><span class=\"ez-toc-section\" id=\"REPLACE\"><\/span><span style=\"color: #0000ff\">=REPLACE<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000\"><strong>STEP 3:<\/strong><\/span>\u00a0The Replace\u00a0arguments:<\/p>\n<h2><span class=\"ez-toc-section\" id=\"old_text\"><\/span><em><strong><span style=\"color: #0000ff\">old_text<\/span><\/strong><\/em><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>Which text do we want to change?<\/strong><\/p>\n<p><em>Reference the cell that contains the text string:<\/em><\/p>\n<h2 style=\"text-align: center\"><span style=\"color: #000000\">=REPLACE<\/span><span style=\"color: #0000ff\">(C11,<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-02.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4900\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-02.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"593\" height=\"210\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-02.png 593w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-02-300x106.png 300w\" sizes=\"(max-width: 593px) 100vw, 593px\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"start_num\"><\/span><em><strong><span style=\"color: #0000ff\">start_num<\/span><\/strong><\/em><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>Which character do we want to start the replacement from?<\/strong><\/p>\n<p><em>We want to replace the first name, which resides on the first character:<\/em><\/p>\n<h2 style=\"text-align: center\"><span style=\"color: #000000\">=REPLACE<\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\">(C11,<\/span>\u00a01,<\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i\"><\/span>\u00a0<a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-03.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4901\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-03.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"600\" height=\"216\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-03.png 600w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-03-300x108.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"num_chars\"><\/span><em><strong><span style=\"color: #0000ff\">num_chars<\/span><\/strong><\/em><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>How many characters do we need to replace?<\/strong><\/p>\n<p><em>We don&#8217;t have the exact number of characters, so this is where the SEARCH function comes in handy from <strong>STEP 1<\/strong> above. <\/em><\/p>\n<p><em>Search for the space character <strong>&#8221; &#8220;<\/strong> which tells us the end of the First Name:<\/em><\/p>\n<h2 style=\"text-align: center\"><span style=\"color: #000000\">=REPLACE<\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\">(C11, 1,<\/span>\u00a0SEARCH(&#8221; &#8220;, C11),<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-04.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4902\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-04.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"600\" height=\"212\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-04.png 600w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-04-300x106.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h2><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"new_text\"><\/span><em><strong><span style=\"color: #0000ff\">new_text<\/span><\/strong><\/em><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>What text will serve as the replacement?<\/strong><\/p>\n<p><em>Now that we have accounted for all the characters from the First Name, we need to clear these.<\/em><\/p>\n<p><em>We can do this by replacing it with an empty string. <\/em><\/p>\n<p><em>This will &#8220;erase&#8221; the First Name, and leave us with the Last Name.<\/em><\/p>\n<h2 style=\"text-align: center\"><span style=\"color: #000000\">=REPLACE<\/span><span style=\"color: #0000ff\"><span style=\"color: #000000\">(C11, 1, SEARCH(&#8221; &#8220;, C11),<\/span>\u00a0&#8220;&#8221;)<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-05.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4903\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-05.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"622\" height=\"219\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-05.png 622w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-05-300x106.png 300w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000\"><strong>STEP 4:<\/strong> <\/span>Do the same for the rest of the cells by dragging the <b>REPLACE\u00a0<\/b>formula all the way down using the left mouse button.<\/p>\n<p>Now we have all of the last names:<\/p>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Extract Last Name with Excel\u2019s REPLACE Formula\" class=\"alignnone size-full wp-image-4904\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06.png\" alt=\"Extract Last Name with Excel\u2019s REPLACE Formula\" width=\"513\" height=\"237\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06.png 513w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2016\/10\/Replace-Extract-Last-Name-06-300x139.png 300w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What does it do? Replaces part of a text string, based on the number of characters you specify, with a different text string Formula breakdown: =REPLACE(old_text, start_num, num_chars, new_text) What it means: =REPLACE(this cell, starting from this number, all the way to this number, with this new text) I had a scenario where I wanted [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":17482,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cos_headline_score":0,"cos_seo_score":0,"cos_headline_text":"Extract Last Name with Excel\u2019s REPLACE Formula","cos_headline_has_been_analyzed":false,"cos_last_analyzed_headline":[],"om_disable_all_campaigns":false},"categories":[3,304,14],"tags":[142,188,70],"acf":[],"_links":{"self":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/4896"}],"collection":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/comments?post=4896"}],"version-history":[{"count":0,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/4896\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media\/17482"}],"wp:attachment":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media?parent=4896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/categories?post=4896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/tags?post=4896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}