delete string before last colon if no text after last colon

  • I found the following formula on another site that deletes all the text before the last colon (it deletes the colon as well)


    =TRIM(RIGHT(M2,LEN(M2)-SEARCH("@#",SUBSTITUTE(M2,":","@#",LEN(M2)-LEN(SUBSTITUTE(M2,":",""))))))


    Is it possible to modify it so that it only triggers if there is nothing after the last colon?


    As you can see in the example below I have some notes entered by users and I would like to delete the ones where they didn't actually enter a note after the last colon:


    [TABLE="width: 735"]

    [tr]


    [td]

    11/05/2012 13:19:53 NEW MIKE : cld poe male sd cu not in till 3pm

    [/td]


    [/tr]


    [tr]


    [td]

    10/18/2012 08:03:55 NEW HOSSEN : called no answer

    [/td]


    [/tr]


    [tr]


    [td]

    10/15/2012 11:15:41 NEW HOSSEN :

    [/td]


    [/tr]


    [tr]


    [td]

    10/12/2012 08:00:26 NEW HOSSEN :

    [/td]


    [/tr]


    [tr]


    [td]

    10/11/2012 12:17:14 NEW HOSSEN : called no answer

    [/td]


    [/tr]


    [tr]


    [td]

    11/14/2012 13:42:07 ACT MIKE : cld poe spk to cust sd cm back at 330


    I would like to be left with just this instead:


    [TABLE="width: 735"]

    [tr]


    [td]

    11/05/2012 13:19:53 NEW MIKE : cld poe male sd cu not in till 3pm

    [/td]


    [/tr]


    [tr]


    [td]

    10/18/2012 08:03:55 NEW HOSSEN : called no answer
    [TABLE="width: 735"]

    [tr]


    [td]

    10/11/2012 12:17:14 NEW HOSSEN : called no answer

    [/td]


    [/tr]


    [tr]


    [td]

    11/14/2012 13:42:07 ACT MIKE : cld poe spk to cust sd cm back at 330

    [/td]


    [/tr]


    [/TABLE]

    [/td]


    [/tr]


    [/TABLE]


    Link to article I found this formula in: http://www.mrexcel.com/forum/e…particular-character.html

    [/td]


    [/tr]


    [tr]


    [td][/td]


    [/tr]


    [/TABLE]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!