+ Reply to Thread
Results 1 to 8 of 8

delete entire row if it doesn't contains at least 1 of the words listed

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Bosnia and Herzegovina
    MS-Off Ver
    Excel 2010
    Posts
    35

    delete entire row if it doesn't contains at least 1 of the words listed

    I've got a web query that daily gets about 8k rows of data.
    I can filter out via filter in excel,but its slow,since i've got to keep data for about 50,60 entries.Rest of them i dont need.

    So,a VBA or Macro that checks the row by row,then checks if that row contains one of a 60 words i pre-inputed,and then keeps those rows who got a match,while deleting any others.

  2. #2
    Forum Contributor
    Join Date
    02-24-2011
    Location
    Belfast, N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    4evra,

    Would you be able to post a dummy section of workbook to show the layout etc. (no need for 8000 rows of data )

    Will the words be within a text string in a cell or will each word be the only thing in the cell?
    Will the words always appear in the same column or will that change?

    Mowgli

  3. #3
    Registered User
    Join Date
    01-25-2013
    Location
    Bosnia and Herzegovina
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    example.xlsx
    Not each cell contains only 1 word.Some columns contain 2,maybe 3 words.
    BUT,words i plan on checking are always 1 word(no spaces),and they are located inside "igrac" columns(which will be columns B and F)

    So,i want the context of cells B and F to be crosschecked with some words i name in a list somewhere in excel,then,if one of those words is located in a specific row,that row is kept from deletion.


    In that excel file,for example,my "name list" would contain words : "Schwaba","bob78"
    Thus,when i execute the code,row 3 and row 6 would be kept in excel,since they contain those words.Other rows would be deleted.
    Last edited by 4evra; 01-30-2013 at 09:33 AM.

  4. #4
    Forum Contributor
    Join Date
    02-24-2011
    Location
    Belfast, N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    103

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    4evra,

    I am still quite the novice at VBA (this is my first post using variables even, however I think this will carry out the job you want it to do. Am happy for anyone to modify and tidy it up some though
    Please Login or Register  to view this content.
    The first section is where you list the variables and what their values will be, I only included 4 but that can be expanded
    In each section for checking the columns B & F data I have only included the first 2 words however you can expand this out also
    The range where you keep the list of names can be changed however at present it looks at column A in sheet 2

    Hope this is of some help,

    Mowgli

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    Another to consider. Also relys on Sheet2 as having the list.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-25-2013
    Location
    Bosnia and Herzegovina
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    @mowgli
    Hmm,i input data into A fields on sheet2,but after i execute the macro,all entries get deteled.
    I tested on the example excel.
    Tried manually inputing words.Same thing.

    I see that u mark the rows for keeping by "keep" tag.
    I deleted the part of code that deletes rows,just to see if the 'keep' tag gets inputed into L column.
    And it doesnt.
    Not sure why though,code i clearly ok,since debugger doesn't throw up any errors for all.
    I'll look into it more closely once i get home and then i'll post some more info about the whole thing

    @John
    Your code works

    Many thanks to both of you

    p.s. even though i've got solution to my problem,i'm still gonna try to brainstorm that code of yours mowgli,just to try to help you in your VBA learning
    Last edited by 4evra; 01-30-2013 at 02:03 PM.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    You're welcome.
    Last edited by JOHN H. DAVIS; 01-30-2013 at 02:15 PM.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: delete entire row if it doesn't contains at least 1 of the words listed

    You're welcome. Glad to help out, and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ 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