+ Reply to Thread
Results 1 to 6 of 6

Delete everything after a certain word

  1. #1
    Registered User
    Join Date
    04-22-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    13

    Delete everything after a certain word

    Hi!

    I'm constructing a macro for formatting a large chunk of data. As part of that program I need some code that deletes everything in a cell after the words/letters "m hu". Since it's part of a larger code I need to do it in VBA. Any suggestions?

    Added info:

    This is the code preceding my problem:

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Please Login or Register  to view this content.
    What I want to do is to change the final line so that it doesn't just replace "m hu" with "", but also deletes all text that might follow. Any suggestions?

    Thanks in advance!
    Last edited by 6StringJazzer; 04-22-2014 at 05:06 PM.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Qu嶵ec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Delete everything after a certain word

    Hi and welcome to the forum,

    This is how I would do it.
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Delete everything after a certain word

    Try this update shown in red:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Expert
    Join Date
    08-02-2013
    Location
    Qu嶵ec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Delete everything after a certain word

    or rather like this since your data is in C1 :

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-22-2014
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Delete everything after a certain word

    Thanks guys!

    Both your solutions worked perfectly.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Delete everything after a certain word

    You're welcome! If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved.

    Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon below their name.

+ 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. Delete Word
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-12-2013, 03:45 PM
  2. Delete Specific Row up to a certain word
    By jesse77581 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-16-2013, 11:25 AM
  3. Find A Word, Delete That Row And The Next 9
    By KeithT in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 11-08-2011, 01:36 PM
  4. Delete Rows not containing a word
    By ryanj4314 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2010, 05:09 AM
  5. Delete all Word Objects only
    By roasty_1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2008, 05:17 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