+ Reply to Thread
Results 1 to 9 of 9

Extract Text Between 2 Dash "-" Symbols

  1. #1
    Registered User
    Join Date
    03-26-2021
    Location
    Fort Worth, TX
    MS-Off Ver
    365
    Posts
    51

    Extract Text Between 2 Dash "-" Symbols

    So what I'm trying to do is have a formula that can extract text that's separated by a "-" symbol. For example, I will receive an email with the subject line "Project - Location - Description" the problem is that the project/location is not always the same length of text so I cant use a middle, left, or right formula. What I need is a formula that starts and stops with the use of a "-" sign. I've attached an example below of what I would like it to do.

    Input Subject Output (What I want)
    ProjectA - New York City, NY - Expiration Date New York City, NY
    Project123 - Orlando, FL - Closing Date Orlando, FL

    How can I do this? Bonus points if you can apply it to the beginning project or end description as well. Any help would be appreciated!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,944

    Re: Extract Text Between 2 Dash "-" Symbols

    Can be quickly achieved with Power Query/Get and Transform Data found on the Data Tab of the Ribbon

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,858

    Re: Extract Text Between 2 Dash "-" Symbols

    At the risk of angering an Excel community, but I think Google Sheets' SPLIT() function is appropriate for this task. =INDEX(SPLIT(text,"-"),2) will return the middle text. If you want all three, just enter =SPLIT(text,"-") and Sheets will output all three parts of the text.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Extract Text Between 2 Dash "-" Symbols

    Quote Originally Posted by mstark17 View Post
    Bonus points if you can apply it to the beginning project or end description as well. Any help would be appreciated!
    I'll go for the bonus points with an old fashioned solution
    split.png

    Please try the following in B2 copied across to col-D then down as far as you need.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by GeoffW283; 10-04-2021 at 09:16 PM.
    Geoff

    Did I help significantly? If you wish, click on * Add Reputation to say thanks.
    If your problem has been resolved please select ?Solved? from the Thread Tools menu

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Extract Text Between 2 Dash "-" Symbols

    Couldn't you just use Text to columns (using Delimited option, and specifying the dash as the delimiter) to separate all three out?
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    03-26-2021
    Location
    Fort Worth, TX
    MS-Off Ver
    365
    Posts
    51

    Re: Extract Text Between 2 Dash "-" Symbols

    Thanks everyone, @GeoffW283 & @alansidman. I've gotten both of your solutions to work. Just need to figure out which one works best for my application of them. Thanks

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,621

    Re: Extract Text Between 2 Dash "-" Symbols

    Late to the party but, as you have Office 365, you could use FILTERXML:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,944

    Re: Extract Text Between 2 Dash "-" Symbols

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  9. #9
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Extract Text Between 2 Dash "-" Symbols

    mstark17: Thanks for the feedback and rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 08-01-2018, 12:27 PM
  2. [SOLVED] How two extract text behind last dash"-" from multiple dash "-" containing text?
    By nabinprd1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2018, 12:16 PM
  3. Replies: 9
    Last Post: 03-05-2016, 12:53 AM
  4. [SOLVED] EXTRACT TEXT "SHM" or "SHGB"
    By Jhon Mustofa in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-29-2014, 07:57 AM
  5. Trying to extract "Text" inbetween ":" and ","
    By Paulzr27 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-06-2013, 05:48 AM
  6. [SOLVED] How to get a Dash"-" in string , when extract using GetMatch Function?
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-24-2013, 01:29 AM
  7. Replies: 1
    Last Post: 10-22-2012, 09:38 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1