{"id":5776,"date":"2017-02-13T17:50:17","date_gmt":"2017-02-13T16:50:17","guid":{"rendered":"https:\/\/www.myexcelonline.com\/?p=5776"},"modified":"2023-11-30T20:59:33","modified_gmt":"2023-11-30T19:59:33","slug":"clear-everything-hyphen-excels-replace-formula","status":"publish","type":"post","link":"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/clear-everything-hyphen-excels-replace-formula\/","title":{"rendered":"Clear Everything Before the Hyphen with Excel&#8217;s 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, with a different text string<\/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, start_num, num_chars,<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;\">, starting from this number, all the way to this number,<span style=\"color: #ff6600;\"> with this new text<\/span><\/span><\/span><\/span>)<\/p>\n<hr \/>\n<p>Once I was given a list of phone numbers in their international format. \u00a0But for my needs, I did not want to include the country code and I just wanted the phone number.<\/p>\n<p>I was looking for a quick way to remove the country code.<\/p>\n<p>I discovered a cool way to do this using the\u00a0<strong>REPLACE\u00a0<\/strong>formula! Goodbye to manual adjustments!<\/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\/_IBZ0PeWVIA?rel=0 \" width=\"800\" height=\"400\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; 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\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen.xlsx\" target=\"_blank\" rel=\"noopener noreferrer\" data-leadbox=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen.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-FORMULA-Clear-before-hyphen.xlsx<\/span><\/a><\/p>\n<p class=\"line-two\">\n<\/div>\n<p><span style=\"color: #ff0000;\"><strong>STEP 1:<\/strong> <\/span>We 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\/clear-everything-hyphen-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\/clear-everything-hyphen-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\/clear-everything-hyphen-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\/clear-everything-hyphen-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\/clear-everything-hyphen-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\/clear-everything-hyphen-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><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-01.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\"  class=\"alignnone size-full wp-image-5778\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-01.png\" alt=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\" width=\"642\" height=\"200\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-01.png 642w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-01-300x93.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 2:<\/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;\">(C10,<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-02.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\"  class=\"alignnone size-full wp-image-5779\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-02.png\" alt=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\" width=\"553\" height=\"198\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-02.png 553w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-02-300x107.png 300w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><\/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 remove the country code, so it starts from 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;\">(C10,<\/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\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-03.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\"  class=\"alignnone size-full wp-image-5780\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-03.png\" alt=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\" width=\"547\" height=\"205\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-03.png 547w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-03-300x112.png 300w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/a><span class=\"ez-toc-section-end\"><\/span><\/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 want to replace?<\/strong><\/p>\n<p><em>We want to remove all characters up to and including\u00a0the first hyphen.<\/em><\/p>\n<p>We will use the <em><strong>FIND\u00a0<\/strong><\/em>formula.<\/p>\n<p><em><strong>FIND(&#8220;-&#8220;, C10)<\/strong> <\/em>will get the location of the first hyphen.<\/p>\n<h2 style=\"text-align: center;\"><span style=\"color: #000000;\">=REPLACE<\/span><span style=\"color: #0000ff;\"><span style=\"color: #000000;\">(C10, 1,<\/span>\u00a0FIND(&#8220;-&#8220;, C10),<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-04.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\"  class=\"alignnone size-full wp-image-5781\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-04.png\" alt=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\" width=\"553\" height=\"202\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-04.png 553w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-04-300x110.png 300w\" sizes=\"(max-width: 553px) 100vw, 553px\" \/><\/a><\/p>\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>Since we want to remove this, you guessed it! We want the value to be an empty string which is depicted by the double quotations.<\/em><\/p>\n<h2 style=\"text-align: center;\"><span style=\"color: #000000;\">=REPLACE<\/span><span style=\"color: #0000ff;\"><span style=\"color: #000000;\">(C10, 1, FIND(&#8220;-&#8220;, C10),<\/span> &#8221; &#8220;)<\/span><\/h2>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-05.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\"  class=\"alignnone size-full wp-image-5782\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-05.png\" alt=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\" width=\"563\" height=\"204\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-05.png 563w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-05-300x109.png 300w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 3:<\/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>Note that all of the phone numbers\u00a0are now clean:<\/p>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-06.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" title=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\"  class=\"alignnone size-full wp-image-5783\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-06.png\" alt=\"Clear Everything Before the Hyphen with Excel&#039;s REPLACE Formula\" width=\"478\" height=\"223\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-06.png 478w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/01\/REPLACE-FORMULA-Clear-before-hyphen-06-300x140.png 300w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/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) Once I was given a list of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":17582,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cos_headline_score":0,"cos_seo_score":0,"cos_headline_text":"","cos_headline_has_been_analyzed":false,"cos_last_analyzed_headline":[],"om_disable_all_campaigns":false},"categories":[3,304,14],"tags":[223,142,188],"acf":[],"_links":{"self":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/5776"}],"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=5776"}],"version-history":[{"count":0,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/5776\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media\/17582"}],"wp:attachment":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media?parent=5776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/categories?post=5776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/tags?post=5776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}