remove specific text and dates within a cell

  • I am trying to remove selected strings of text and the date associated with them from a large number of customer account records.


    For example, I have the following text in a single cell;


    09/02/2011 DRNAgencyProcess CLOSE NB1X1691 5 ACMCLS RECALLED BY CLIENT 08/20/2010 Agent Forced to close case 08/13/2010 Agent no acct to transfer, no unposted payment,called customer thru number 780-691-3164 as per recording number is not recognized mailbox.updated to 111-1111.no other number listed.future credit events already in place./u2ds 06/12/2010 Agent Event Status Date Changed to 2010-06-11. Event Status Changed to Completed . 06/12/2010 Agent Create Event


    Many of the comments are system generated and/or repetitive and I am trying to strip them out. To look at the comments individually they look like this;


    09/02/2011 DRNAgencyProcess CLOSE NB1X1691 5 ACMCLS RECALLED BY CLIENT
    08/20/2010 Agent Forced to close case
    08/13/2010 Agent no acct to transfer, no unposted payment,called customer thru number xxx-xxx-3164 as per recording number is not recognized mailbox.updated to 111-1111.no other number listed.future credit events already in place./u2ds
    06/12/2010 Agent Event Status Date Changed to 2010-06-11. Event Status Changed to Completed
    06/12/2010 Agent Create Event


    The only comment I want to keep from the above example is the one starting with "08/13/2010 Agent no acct to transfer...". The rest I want to delete. I am currently using Replace to remove repetitive comments like "Agent Create Event" but I can't figure out how to remove the date associated with it so I end up with a bunch of dates with no text between most of them. I tried modifying the code below from another post but could not get it to work.


  • Re: remove specific text and dates within a cell


    Perhaps I can simplify my request by simply asking; how can I remove the dates from a long string of text in a single cell containing multiple dates and snippets of text and where the dates are in the format "mm/dd/yyyy". eg. 05/26/2010

  • Re: remove specific text and dates within a cell


    Thanks for the suggestion Jindon. I tried to use that by modifying some of my current code but I couldn't get it to work. Basically I am using statements like:

    Code
    s = Cells(row, 6).Value
    Cells(row, 6).Value = Replace(s, " Agent Create Event", "")


    to remove the redundant phrases but I was unable to get it to work using ??/??/???? to remove the dates as you suggest.

  • Re: remove specific text and dates within a cell


    It should be Replace method of a range object so something like

    Code
    Cells(row, 6).Replace "??/??/????", ""


    Or if you want to apply all the cells then

    Code
    Cells.Replace "??/??/????",""

Participate now!

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