+ Reply to Thread
Results 1 to 21 of 21

Delete rows based on lower value than number specified , positive or negative values

  1. #1
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Delete rows based on lower value than number specified , positive or negative values

    Hey guys

    I am trying to find a solution to my problem but I think I'd need someone with a bit more brains than me :P I am trying to delete rows based on the value of four columns, Column Q ; R & S ; T.
    But here is the catch, the values in those columns are positive and negative,and lets say my deleting criteria is : 3 then I want all rows deleted is small than 3 , that would be either -3 or +3 . So lets say the column has a -4 then I want the macro to see that the number is ''greater'' then 3 and therefor not delete it. The macro should read both positive and negative numbers if you understand what I'm saying

    I'll include the a test piece of the document I am working on with this post.
    About the document:

    •Values I want this macro to read is located in columns Q ; R & S ; T all the way down till there is no data left ( the size of the data in my document will always be different)

    •The deleted rows should be shifted up after deletion.

    •The value that I want to be using for deleting criteria is +\-4 ( so that would mean anything gets deleted 'below' that number example: 3 & -4 and numbers like -5 ; -4 ; -7 will not be deleted because they have a ''higher'' number than 4)

    Thanks for reading , any type of help I appreciate and value, thanks all
    Attached Files Attached Files

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    so, you want a row deleted if any of the values in columns P,Q,R, and S (for that row) have an absolute value greater than 4?
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Yes , exactly that, Sorry if this is a stupid problem, but hoping it to be possible in macro form , since other people will be using this document to filter out data and they are not good at excel themselves. Thus making it easier if this was a written macro

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    Edit: Had the loop counter working the wrong direction, try this one :D

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by GeneralDisarray; 06-03-2013 at 08:53 AM.

  5. #5
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Hey Disarray

    I tried your code out, thanks for attacking the problem so quickly :P but the code seems to not run as smoothly, it gives me a ''Run time error '13' '' is there anything I should change in the code?

  6. #6
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    I only see your cool button feature now like it ! somewhere a link is still missing though , it does not appear to remove those rows yet..

  7. #7
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    ok, i uploaded a second version (did you get that one?)

    i had initially looped the wrong direction...

    Basically, when you are looking to delete from a range, you need to start at the bottom and work your way up. Otherwise, you will end up skipping rows (because the data moves up after each delete).

    Anyway, I've tested the loop on the sheet you sent by adding values with an absolute value > 4 (in columns p,q,r,s). seems to be working :D
    Last edited by GeneralDisarray; 06-03-2013 at 09:08 AM.

  8. #8
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    I tried the one you inserted into my book , that one didn't work so well, and then I tried to just copy your code into a new macro, and that gave me the run error. We are almost there ! ^^ perhaps I could make you a cup of coffee while you have a brain storm about it

  9. #9
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    please upload the workbook you are using that is giving you the error and i will see what i can do.

  10. #10
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Here is your downloaded workbook which I have now, the button does not seem to remove any numbers lower than +/- 4
    Attached Files Attached Files

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    Lower than?

    Ok. I think you meant "No" and not "Yes" to my original question.

    So, if there is a number between -4 and +4 present in p,q,r,s THEN do delete. If the number is outside of this.... then don't delete.

    DO Delete Examples: -3.99, -3, -2, -1, 0, 1, 2, 3, 3.999 => DELETE

    DON'T Delete Examples: 4, 5, 6,7 ... -4, -5, -6, -7 => LEAVE IN PLACE


    ---

    Just change the direction of the inequalities:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by GeneralDisarray; 06-03-2013 at 09:54 AM.

  12. #12
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Ah, thanks. It is working, but I see now my mistake as well... the one column has only 0's in it, and sometimes that will differ, sometimes another column might have a series of zeroes in it and because that cell has zeroes it will always delete all lines regardless of the column next to it having a number greater than 4 . Is it possible to adjust it the macro that if there is a cell that has that greater number than 4 in it that it does not delete the row regardless of the cell next to it having a zero?


    Turned out a bit more complicated than I first thought it would, sorry , but thanks for helping thus far.

  13. #13
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values



    well, sure. But let me make sure i understand :D

    If column P is showing a 0, but Column Q = 5 (for instance). Then you don't want it deleted.


    This code would just ignore Zeros altogether. Is that what you need?
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Hi Disarray , apologize I never got back to you earlier, I just fell asleep haha . Well what you explained is exactly what I want yes,however when I tried your code it told me ''type mismatch'' >_>

  15. #15
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    Well, i can't get it to break on what you sent out before. I updated the macro with the addtional logic, and it still works.

    Maybe you can post your actual book that is breaking?


    Also, everything you sent is being deleted because of the S column values. But if I change the S column to a number with an absolute value > 4, then it remains. So the "ignore zeros" logic is working here.


    Attached Files Attached Files
    Last edited by GeneralDisarray; 06-04-2013 at 10:14 AM.

  16. #16
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    I think there is something strange happening here, because even though it is working for you, on the workbook that you last posted, if I run the macro from the view macro list then it deletes all the data because of the zeroes... I'll post my original workbook for you now, you can have a look.

    Go to the last worksheet called ''Raw Data''
    Hope we get this funny business sorted, you are pretty funny when I get you confused :P Maybe I'm just not that good at explaining >_> or lets rather blame it all on the workbook
    Attached Files Attached Files

  17. #17
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    Quote Originally Posted by GeneralDisarray View Post

    Also, everything you sent is being deleted because of the S column values. But if I change the S column to a number with an absolute value > 4, then it remains. So the "ignore zeros" logic is working here.
    It's not because of the zeros. The S values all have an absolute value less than 4. Wasn't part of the condition you described to remove rows? Do you not want to check column S or are you looking to keep a row if some of the values are 'higher' than 4 (even if other columns have values lower)?

    Can you clarify what the delete condition is again?

  18. #18
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Hi Disarray, thanks for your patience with this one, okay, to clarify the delete conditions: if the value within any of the two columns is less then 4 , the row gets deleted. That would mean -3, 3.9 ,2 , -1 all deleted & -4.1 , 4 , -7 .-8 , 5 All remain in the sheet. But lets say one column cell is 2 and the other column cell ( in the same row) is 4.2 then I'd want this row not to be deleted.

    Hope that's good and clear, any question please ask, attaching my workbook I'm using right now with your latest code in, but the code still deletes everything though =(

    Cheers
    Attached Files Attached Files

  19. #19
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Delete rows based on lower value than number specified , positive or negative values

    Give me some more examples please. You say, "if the value within any two of the columns is less than 4, the row gets deleted" but then you say "[if] on column cell is 2 and the other column cell (in the same row) is 4.2 then I'd want this row not to be deleted."

    But, based on your first statement, doesn't it matter what the other values are? Please provide more examples that will illustrate the rows to keep and the rows to delete -- actually, take the previous example we've been posting back and forth and just highlight the rows you would delete. I think if you do that I will be able to figure out what you need.

  20. #20
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Okay, I did a few examples for you ^^

    Attached is the workbook.
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    05-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Delete rows based on lower value than number specified , positive or negative values

    Hi Disarray

    The workbook I last attached has the example deleted rows high lighted, I'm just wondering if we could continue working on this one, how do you feel? Sorry >_> but I urgently need this to try and work, I have a deadline coming up really soon and this code would really mean allot to me, anyone else reading , please don't feel shy to pitch in, I would appreciate it <3
    Last edited by LadyNicole; 06-11-2013 at 03:39 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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