+ Reply to Thread
Results 1 to 18 of 18

Code to delete text left of a specific character

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    57

    Code to delete text left of a specific character

    I am writing a VBA macro which delimit a column of raw text into usable data. I figured out how to delimit specific characters, but I still need to clean it up. Some of the cells are preceded by a date and name, such as...

    Date: Name: 100
    150
    125
    Date: Name: 225
    275

    ...and I want to remove all that text from the cell. So basically a code that will delete any text to the left of any ":"

    Thanks!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to delete text left of a specific character

    With nothing else to go on this will fix your active cell:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Code to delete text left of a specific character

    Assuming the strings are in col. A, you may also try this.......
    Please Login or Register  to view this content.
    Last edited by sktneer; 10-11-2014 at 11:23 PM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Thumbs down Re: Code to delete text left of a specific character

    I guess its simple..
    Try find and replacing "*:" with Nothing ("") without Quotes
    To be more precise, you can select the Target Range of cells where in the replacement has to be done...
    or you can try this simple
    Please Login or Register  to view this content.
    Check the attached file..
    Attached Files Attached Files
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to delete text left of a specific character

    A more useful form:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Code to delete text left of a specific character

    Thanks for your valuable response Yoshi...

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Another way …

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-06-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    57

    Re: Code to delete text left of a specific character

    Hey guys

    Very sorry I lost track of this thread/project for the past week and didn't respond! Skneer's code was originally working for me, but now when I try to use it, it seems to not be working properly. Not sure if I changed some setting in excel or what.

    I am now using xladept's code with one revision, which now causes the code to be performed on only row A rather than the entire sheet:

    Please Login or Register  to view this content.
    Again my apologies for my lack of follow up. Thanks to everyone for the help!

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to delete text left of a specific character

    You're welcome and thanks for the rep!

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Code to delete text left of a specific character


    Should be faster by combinating Find method and Split function …

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to delete text left of a specific character

    @ Marc L - Maybe faster is relative - the one operation will be bypassed by my code but your code would process every one??

  12. #12
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Code to delete text left of a specific character

    What about this ?

    Please Login or Register  to view this content.
    Kris

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Code to delete text left of a specific character

    Quote Originally Posted by xladept View Post
    @ Marc L - Maybe faster is relative - the one operation will be bypassed by my code but your code would process every one??
    ???

    Split only cells from Find method …

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Code to delete text left of a specific character

    @ Marc L - like this?

    Please Login or Register  to view this content.
    Last edited by xladept; 10-20-2014 at 01:51 PM.

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Thumbs up Re: Code to delete text left of a specific character


    In the great lines …

    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Code to delete text left of a specific character


    Thanks for the Rep' !

    TBTO rule : Think, But Think Object !

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Code to delete text left of a specific character


    See also post #12 great code ! EVALUATE is a powerful function able to work as a matrix formula.

  18. #18
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Code to delete text left of a specific character

    Better late than never

    Try:
    Please Login or Register  to view this content.
    Note: I have assumed you have nothing in Column B.. if you do.. just change the first line to suit..
    Last edited by apo; 10-21-2014 at 05:47 AM. Reason: Streamlined code further..

+ 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. [SOLVED] How to use LEFT and RIGHT to delete last character
    By nicolaivinther in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-06-2014, 09:53 AM
  2. [SOLVED] Extract text to left of nth character
    By cmb80 in forum Excel General
    Replies: 3
    Last Post: 06-16-2014, 11:09 AM
  3. [SOLVED] Find text left or right of a specific character in a text string
    By Locopete99 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-14-2014, 05:55 AM
  4. [SOLVED] Left/Right function in VBA, finding a specific starting character
    By astronut325 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2012, 01:26 AM
  5. Macro to find character and delete all text in cell after the character
    By SpencerRichman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2012, 06:08 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