+ Reply to Thread
Results 1 to 15 of 15

Delete Rows based on criteria.

  1. #1
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Delete Rows based on criteria.

    Hello everyone,

    I had a raw data sheet in which i need to prepare a statement just like the attached worksheet.

    My requirement is to delete all those rows in the department column except the department which starts with "C" Just like "CNN" & "CNN-IN".

    Rows with data containing the words starting with "CNN" should not be deleted .The rows can contain words with "CNN" or "CNN*"(here * denotes anything after the word CNN)

    I had just formatted the whole worksheet for easy reference.Actually the raw data is extracted from other program which is very clumsy & irregular.

    The department column might be in any column.
    Please tell me the easy way out.
    Attached Files Attached Files
    Last edited by excelkeechak; 01-31-2010 at 09:59 PM.
    THANKS
    ExcelKeechak

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Delete Rows based on criteria.

    the sheet seems to be sorted by column A. If yo want to retain this sort order:

    sort by department
    delete rows before CNN entries
    delete rows after CNN entries
    sort by column A

  3. #3
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Re: Delete Rows based on criteria.

    Hi teylyn, thanks for the fast reply.Yes, as i said earlier the whole data is extracted from other program.What i want is to delete only those rows which dont contain the words Starting with "CNN" in the department column & the department column will be any where to the right side of the AMOUNT column.

    I need to delete all those unncessary Rows & columns in between those of Amount & department column and also delete the rows which dont start with the department name "CNN"
    Hope i made it clear

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Delete Rows based on criteria.

    Hi excelkeechak
    It would help me if you would post a copy of your extracted raw data. The data you posted has been
    formatted the whole worksheet for easy reference
    I'd like to see the data before it's been formatted so I can see what the options are.
    John
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Delete Rows based on criteria.

    I need to delete all those unncessary Rows & columns in between those of Amount & department column and also delete the rows which dont start with the department name "CNN"
    Hope i made it clear
    Afraid not. What do you mean by "rows & columns in between those of amount & department"? There is no column between Amount and department in your example.

    My suggestions shows you a way to quickly delete all rows that do not start with "CNN" in the column labeled department. If that is not what you require, please give a better example.

    You may want to mock up a "before" and "after" sheet to illustrate your point.

  6. #6
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Re: Delete Rows based on criteria.

    Due to integrity reasons i cannot post it.Sorry for that.
    Let me know the code if there is any possibility of copying all the rows which contain the word CNN & CNN*.* in the department column and paste it into a new worksheet.

  7. #7
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Re: Delete Rows based on criteria.

    Hmmm.Ok.based on my original data.i m trying to give a sample data.my Original data looks similar to the sample data i had attached.what i want is to find and copy all those rows to a new worksheet whose departments are "CNN" or which start with "C*"(Just Like CNN-IN).

    I had uploaded a new example for reference.Kindly help.
    Attached Files Attached Files
    Last edited by excelkeechak; 01-26-2010 at 09:35 AM.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Delete Rows based on criteria.

    Hi excelkeechak
    I may be able to help you with this, however, your "Raw Data" worksheet seems to bear no relationship to your "req format" worksheet. Things don't appear to add up?
    I'll take a stab at it but it may not be what you're looking for.
    John

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete Rows based on criteria.

    Try this on a copy of that sheet you uploaded in post #7. It will format that sheet to the specified layout.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  10. #10
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Re: Delete Rows based on criteria.

    Yes, Exactly this is what i needed.Thanks Very Much JBeaucaire for the code.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete Rows based on criteria.

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)

  12. #12
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Re: Delete Rows based on criteria.

    I had one more requirement please,what would be the generalized code for the same scenario just like
    Please Login or Register  to view this content.
    to remove unwanted rows or columns which are different from the example.
    Last edited by excelkeechak; 01-28-2010 at 10:32 AM.

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete Rows based on criteria.

    This is the lines of code that are filtering data based on cell content, the code you cited above is removing the empty rows/columns.
    Please Login or Register  to view this content.
    I've highlighted the part you need to edit. Currently it is filtering to show rows that do not start with the letter "c". The next line of code deletes them, the third turns the filter back off to reveal the ones left behind, the ones that do start with the letter "c". Based on your question, the code originally given does remove items that do not match.

    So, you can edit that part in red to cause different results. Perhaps:

    "=c*" - only show cells starting with "c"

    If that's not it, just play with it.

  14. #14
    Forum Contributor excelkeechak's Avatar
    Join Date
    07-21-2008
    Location
    India.
    MS-Off Ver
    2013 /2016
    Posts
    363

    Re: Delete Rows based on criteria.

    Thanks JBeaucaire for taking your time in explaining the code.

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete Rows based on criteria.

    Glad to help!

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].


    (Also, use the blue "scales" icon in our posts to leave Reputation Feedback, it is appreciated. It is found across from the "time" in each of our posts.)

+ 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