+ Reply to Thread
Results 1 to 6 of 6

Macro to delete rows that do not contain certain text - search multiple words

  1. #1
    Registered User
    Join Date
    09-24-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Macro to delete rows that do not contain certain text - search multiple words

    Hi!

    I'm new to VBA (working in Excel 2010) and I'm trying to write code that willd delete all rows that do not contain text that matches several words (3 key words in total but 6 different versions since it's case sensitive). So far, I have code that works if I need to search for only two words --> SearchItems = Split("tv", "TV").

    Please help - I've googled the crap out of this and am getting very frustrated since I don't have the necessary background knowledge in VBA to figure this one out. I really appreciate it!!

    Here's what I have so far:

    Please Login or Register  to view this content.
    Last edited by arlu1201; 12-15-2012 at 05:10 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to delete rows that do not contain certain text - search multiple words

    You did not show your 6 words, but you can add to SearchItems like

    SearchItems= Split("word1,word2,word3,word4,word5, word6",",")

    attention, sintax of SearchItems = Split("tv", "TV") is wrong
    Last edited by patel45; 09-25-2012 at 02:21 AM.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    09-24-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Macro to delete rows that do not contain certain text - search multiple words

    Thank you so much!

  4. #4
    Registered User
    Join Date
    09-13-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro to delete rows that do not contain certain text - search multiple words

    Quote Originally Posted by patel45 View Post
    You did not show your 6 words, but you can add to SearchItems like

    SearchItems= Split("word1,word2,word3,word4,word5, word6",",")

    attention, sintax of SearchItems = Split("tv", "TV") is wrong
    I also have similar issue can I expect some help, please?

    Hi

    I am novice excel user and trying to search and found solution to my issue, I came close to it but not yet got what I wanted exactly. I am looking for a macro to delete rows that DO NOT contain criteria. But what I could achieve so far is deleting all rows except the first word ie ACC here. My code so far is as follows

    Please Login or Register  to view this content.
    I see some issue at code marked in red. Need help resolving this. Thanks, in advance
    Last edited by arlu1201; 12-15-2012 at 05:13 AM.

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to delete rows that do not contain certain text - search multiple words

    Masterthetrade,

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.

    Also,

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  6. #6
    Registered User
    Join Date
    09-13-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Macro to delete rows that do not contain certain text - search multiple words

    Arlu1202 Sorry for that...and thanks for raising issue and guiding me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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