+ Reply to Thread
Results 1 to 16 of 16

Identifying words by puntuation marks and deleting.

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Identifying words by puntuation marks and deleting.

    I'm trying to tidy a script by removing the names of the characters.

    Each one in the text is followed directly by a colon or by a space and a colon.

    So , the search would find colons preceded by text characters making single words.

    It would find

    John:
    Sarah:
    Steven:
    Helen:

    and delete each one.


    It would also find

    John :
    Sarah :
    Steven :
    Helen :

    and delete.


    It wouldn't find colons with numerical characters or spaces on either side.

    So it wouldn't find

    21 : 21 : 00

    or

    21:21:00



    Can someone advise a search and replace to satisfy this?

    Grateful for any help...

    Last edited by CDandVinyl; 05-21-2020 at 11:49 AM.
    Using Excel , Word and Access 2003 - For the whole of 2024

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Identifying words by puntuation marks and deleting.

    B1 =if(or(isnumber(mid(a1,search(":",a1,1)-1,1)*1)=true,isnumber(mid(a1,search(":",a1,1)-2,1)*1)=true),a1,left(a1,search(":",a1,1)-1)) and drag down.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Identifying words by puntuation marks and deleting.

    oeldere: And how will that work in Word? It is, after all, a Word question...
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Identifying words by puntuation marks and deleting.

    You could do that with a wildcard Find/Replace, where:
    Find = <[A-Za-z]@[a-z ]:
    Replace = nothing

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Identifying words by puntuation marks and deleting.

    @ macropod

    The footer says.

    Using XL2003 - Feb 1st 2020

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Identifying words by puntuation marks and deleting.

    Sig lines are irrelevant. It's posted in Word Formatting & General.

  7. #7
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    Thanks for this - it's working perfectly first time.

    Last edited by CDandVinyl; 05-20-2020 at 08:51 PM.

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Identifying words by puntuation marks and deleting.

    The wildcard Find/Replace expression I posted finds all those instances and deletes the word preceding the colon.

  9. #9
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    - sorry guys if my signature confused the issue. I'll amend it to avoid any future consternation.


  10. #10
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    The wildcard Find/Replace expression I posted finds all those instances and deletes the word preceding the colon.
    Many thanks again for your time and expertise.

    Problem Solved!

    Last edited by CDandVinyl; 05-20-2020 at 08:51 PM.

  11. #11
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    Just a FYI ;

    I'm finding that where the name is in all capital letters followed immediately by a colon , the search/replace misses them.

    Names with all other combination of upper / lower cases and spaces followed by a colon are found.



  12. #12
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Identifying words by puntuation marks and deleting.

    Quote Originally Posted by CDandVinyl View Post
    I'm finding that where the name is in all capital letters followed immediately by a colon , the search/replace misses them.
    Without wanting to place too fine a point of it, none of your examples depicted that. Nevertheless, to handle that as well, you could use:
    Find = <[A-Za-z]@[A-Za-z ]:

  13. #13
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    You're quite right - apologies. My oversight.

    Your amended code covers all the bases and works perfectly. It's very interesting to work through the logic.

    Thanks again.


  14. #14
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    As feedback - I'm running the Regex code suggested

    Please Login or Register  to view this content.
    and it's working brilliantly to remove the names in my scripts based upon the position of the colon. Whether the name is capital or lower case , whatever the position of spaces or not around the colon , it works.

    In some few circumstances though , where a colon exists elsewhere in the text , it has some unintended consequences.

    For example :

    MARIA : But hark ye :what cunning match have you made.

    Antony: Only this: let each man do his best.


    Should become - with just the names at the start deleted :


    But hark ye :what cunning match have you made.

    Only this: let each man do his best.


    Unfortunately , the code can't pick out specifically the colons with names preceding them. It is finding both colons and rendering these examples as

    But hark what cunning match have you made.

    Only let each man do his best.


    Perhaps I should have thought of this in the initial post.

    I was wondering , as each name is always only at the beginning of a line with no text or spaces preceding it , if there is a way to differentiate it from the other colons in the middle of a phrase which do have text and spaces preceding them.

    The code would not have effect on numbers , and should search irrespective of upper and lower case , and absence or not of spaces.

    Grateful for any advice.

    Last edited by CDandVinyl; 05-21-2020 at 05:58 PM.

  15. #15
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Identifying words by puntuation marks and deleting.

    You could try:
    Find = <[A-Z][A-Za-z]@[A-Za-z ]:
    Do note, however, this will not find colons preceded by a string of less than three characters (including the space).

  16. #16
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Identifying words by puntuation marks and deleting.

    Ok - thanks again. That's fixed it.


+ 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: 12
    Last Post: 02-22-2018, 06:45 AM
  2. Identifying unique words in a column
    By johngearsons in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-02-2016, 04:42 PM
  3. [SOLVED] Bringing back words in quotation marks in a cell
    By Excelfail in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-01-2014, 04:47 PM
  4. Color Code Specific Words and Punctation Marks Within Cells
    By khines19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2014, 05:28 PM
  5. Identifying small letters at the beginning of words
    By Suptilitas in forum Excel General
    Replies: 1
    Last Post: 11-06-2011, 03:46 PM
  6. Finding and deleting question marks
    By jezzica85 in forum Excel General
    Replies: 3
    Last Post: 02-25-2006, 05:10 AM
  7. [SOLVED] I have pound marks in a cell rather than words/letters.
    By claudia riley in forum Excel General
    Replies: 3
    Last Post: 09-16-2005, 02:05 PM

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