+ Reply to Thread
Results 1 to 5 of 5

Remove Text+Numbers Sometimes, Based on Other Text in Cell

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    United States
    MS-Off Ver
    Excel Starter 2010
    Posts
    6

    Remove Text+Numbers Sometimes, Based on Other Text in Cell

    I have a new problem that I'm not sure how to deal with. I only have MS Excel Starter, so I can't use macros, and I don't understand VBA. If there's a formula solution that would be awesome.

    I have the following string of text:

    P2(BB) $50 - VP:53 PFR:39 AF:4.0 W:10|33 STL:69|63 3B:10|67 CB:62|87 N:-109.18 Hands:102

    Sometimes the term "Hands:..." is listed. Sometimes it is not. When it is not listed then I want the data N:.... to be deleted. When it is listed then I want the data N:.... to show up.

    Right now I have the following formula: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LEFT(A5,FIND("N:",A5)-1),"P1","Villain "),"Me","Hero "),"P1","Villain ") (It mostly changes the names at the beginning of the text to Hero or Villain.

    Another way to look at the problem is this: Whenever the string starts with "Me" then I want "N:-109.18" to be deleted. Whenever it starts with anything else I want it to stay. The N:xxxxxxxx can be any length. It will always be preceded and followed by a space. It is always in the same spot relative to the other data in the cell.

    Thanks guys and gals!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Remove Text+Numbers Sometimes, Based on Other Text in Cell

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    06-27-2013
    Location
    United States
    MS-Off Ver
    Excel Starter 2010
    Posts
    6

    Re: Remove Text+Numbers Sometimes, Based on Other Text in Cell

    I have attached a spreadsheet showing what the data looks like in its original forms and what the output should look like.

    Thank you!
    Attached Files Attached Files

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Remove Text+Numbers Sometimes, Based on Other Text in Cell

    maybe

    =IF(ISNUMBER(SEARCH("Hands",A4)),A4,LEFT(A4,FIND("N:",A4)-1))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Remove Text+Numbers Sometimes, Based on Other Text in Cell

    I *think* this is what you want....
    Using your posted workbook:

    This regular formula replaces
    "Me(" with "Hero("
    "P1(" with "Villain"
    AND
    Removes the "N:" phrase if the string begins with "Me("
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Copy that formula down as far as you need.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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