+ Reply to Thread
Results 1 to 11 of 11

delete rows two different criteria

  1. #1
    Registered User
    Join Date
    12-01-2015
    Location
    ballarat
    MS-Off Ver
    2013
    Posts
    85

    delete rows two different criteria

    Hello,
    I am developing my project and would like some assistance please.
    On race days there are certain races I would like to automatically delete from the program.
    Firstly on the heading for each race there is an item relating to the track conditions.
    e.g Good 3.
    Now I would like to be able to check the days meeting and delete any races and the horses where
    the race is classified as Soft 6,Soft 7, Heavy 8,Heavy 9, Heavy 10.
    The second group relates to the number of horses in the race.
    Here I wish to eliminate all races that have less than 8 runners or greater than 18 runners.
    I have enclosed a small sample worksheet.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: delete rows two different criteria

    It's possible, but the format in that excel spreadsheet is a nightmare to work with. Can you upload a document that has been formatted so that all track conditions are in the same column? That and other common-sense formatting would be helpful.

    A split function could be used to separate the string that includes track conditions by spaces, but sometimes the track condition is at the end of the string and sometimes it's not. Perhaps it would be easier to work with if you provided a list of track conditions you could check against.
    Last edited by joe31623; 12-29-2015 at 06:18 PM.

  3. #3
    Registered User
    Join Date
    12-01-2015
    Location
    ballarat
    MS-Off Ver
    2013
    Posts
    85

    Re: delete rows two different criteria

    Hello Joe,
    Thanks for your response.Unfortunately that's what I am up against.
    I did try obtaining the track conditions in the same column but but have been unable to achieve that.
    Sample enclosed.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: delete rows two different criteria

    Hello gilnic,

    The attached workbook has a button on the "result" worksheet to run the macro shown below. The data is cleared each time the macro is run.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: delete rows two different criteria

    Try the attached
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: delete rows two different criteria

    Gilnic -- These two guys impressed me and I learned a lot on this thread! Sometimes I love to be wrong.

    I edited this post to say: If you go with jindon's code, I think you can eliminate the "Gpood 3" from my previous post (I believe to be INCORRECT: "correct Gpood 3" to "Good 3").

    Unless I'm wrong, what that line of code does is sets some conditions to eliminate the Area (that includes a range of cells) and it just so happens "Gpood" never occurs. Perhaps it is there on purpose for debugging purposes.
    Last edited by joe31623; 12-29-2015 at 08:56 PM.

  7. #7
    Registered User
    Join Date
    12-01-2015
    Location
    ballarat
    MS-Off Ver
    2013
    Posts
    85

    Re: delete rows two different criteria

    Hello,
    Thank you all for your contributions. These are greatly appreciated.
    @Joe31623 like you ,I am impressed with the knowledge and skill these members show in assisting others.
    Now I have attempted to try both solutions with a varied set of race meetings including incorrect spellings etc.
    The solution provided by Leith Ross has worked perfectly on all occasions. Thank you.
    Unfortunately when I try to use different race meetings and run the program provided by jindon it clears the sheet of all data. I am not sure what I might be doing wrong as I am not experienced in working with these codes.
    Also as Joe pointed out I would like to know what is the reason for including Gpood in the code.

  8. #8
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: delete rows two different criteria

    Gilnic,

    Many of jindon's solutions that he posts on this forum include Regexp expressions. It is an extremely powerful yet difficult to understand (upon first glance) VB (not VBA) and other coding languages' search method. Based on the syntax, I can tell that Gpood is an error; however, I believe the code works because jindon thought you were to exclude that condition.

    Jindon's solution is designed to clear the sheet of all previous data; however, it can be easily modified to not do that. Since Leith provided you a solution for that, I don't think that is necessary. Let me know if you need further development on this project and I'll be happy to help if I can. I'm not as good as these guys, but I'm learning.

    For further info. on regular expressions, YouTube has a few resources -- including this one: https://www.youtube.com/watch?v=DRR9fOXkfRE

  9. #9
    Registered User
    Join Date
    12-01-2015
    Location
    ballarat
    MS-Off Ver
    2013
    Posts
    85

    Re: delete rows two different criteria

    Hello @jinjon,
    If in another scenario I only want to delete the Heavy 8,9,10 and not the Soft 6-7 is it as simple as deleting the Soft [6-7]|from the formula previously provided.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: delete rows two different criteria

    Quote Originally Posted by gilnic View Post
    Unfortunately when I try to use different race meetings and run the program provided by jindon it clears the sheet of all data. I am not sure what I might be doing wrong as I am not experienced in working with these codes.
    So, no idea.

  11. #11
    Registered User
    Join Date
    12-01-2015
    Location
    ballarat
    MS-Off Ver
    2013
    Posts
    85

    Re: delete rows two different criteria

    Hello @Leith Ross,
    I wonder if you might have the time please to look at the sheet and see why it is not eliminating all the
    <8 starters races.
    These still show in the result sheet.2.43pm,2.47,3.28,5.36 and 7.30pm
    Attached Files Attached Files

+ 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 rows once the two criteria are met
    By lakh4u2001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-31-2014, 03:49 AM
  2. Delete rows with criteria
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2013, 09:50 AM
  3. [SOLVED] how to delete delete rows with criteria and keeping formula
    By Bremmah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2013, 07:09 AM
  4. [SOLVED] Delete certain rows with criteria
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-29-2012, 06:12 PM
  5. [SOLVED] Delete certain rows with criteria
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-28-2012, 01:22 PM
  6. how to delete rows not containing the criteria
    By sasswe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2008, 02:11 AM
  7. vba to delete rows if criteria not met
    By peterkiukas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-24-2007, 03:40 AM

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