+ Reply to Thread
Results 1 to 17 of 17

Macro to delete rows where positive Value is same as negative value in Specific Column

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Macro to delete rows where positive Value is same as negative value in Specific Column

    I have a spreadsheet with several columns


    I need a macro to delete all rows in Col with Header "Bank" in row 1 where the values are positive and equal eg 50 -50 , 150, -150 etc


    I have attached sample data and highlighted the items in yellow where the rows must be deleted



    It would be appreciated if someone could kindly assist me

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    One way...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Thanks for the help. The code works perfectly

    I just need one small change. The hander "Bank" is not always in Col B


    The rows to be deleted where the values are positive and equal eg 50 -50 , 150, -150 etc , will always be in the Column where the header is "Bank" which is in row 1


    It would be appreciated if you could kindly amend your code to accommodate this

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Need to learn my friend...Make use of snippets here


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Thanks for the updated code. Will go through the link to previous code per Snippets Link so that I understand and learn

  6. #6
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Hi Sintek


    the code works perfectly and runs quickly on my same data. However it is very slow when run using real data where the number of rows is +- 600,000


    I have set the code to change calculation to manual, but still take +- 20 mins to run

    it wold be appreciated if you could amend your code to run faster


    I have the autofilter on. Do I first need to set the autofilter off before running the macro ?


    your assistance is most appreciated

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Upload a sample file with a bigger data set

  8. #8
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    See attached sample data


    Kindly test and amend code so that I runs faster

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    See if this helps...
    Please Login or Register  to view this content.

    EDIT....Just noticed the above wont work...There are multiple Pos & Neg values...
    Last edited by sintek; 04-04-2019 at 12:34 PM.

  10. #10
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Thanks for your effort

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Give this a go...
    Not sure if there is a quicker solution...
    Lets see if anyone else comes up with another solution...
    Please Login or Register  to view this content.
    Last edited by sintek; 04-04-2019 at 02:06 PM.

  12. #12
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Thanks foe updated code


    when running macro, it comes up with message (not responding) at end of workbook name


    not sure what would cause that. I have office 2016 (64 Bit)

  13. #13
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    When stepping through the code in Post 11 it takes 2 seconds...
    Running the code hangs....This is a very strange phenomenon...

    Anyone have any ideas...
    Last edited by sintek; 04-04-2019 at 02:10 PM.

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

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Please Login or Register  to view this content.
    Last edited by jindon; 04-04-2019 at 09:30 PM.

  15. #15
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Hi Jindon


    Thanks for the help. Your code works perfectly and completes task in seconds


    Howard

  16. #16
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,765

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Hi Sintek


    I ran your code on my Laptop. It took +- 10 mins to run. Possibly my hardware settings needs to change to take full advantage of my ram which is 8mb


    I am using office 2016 (64 bit)


    Not sure how to change these to increase speed and take full advantage of Ram

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,325

    Re: Macro to delete rows where positive Value is same as negative value in Specific Column

    Yeah, jindon's code always rocks...Still would like to know why when stepping through my code it takes 1.5 seconds but running it ... hangs...

+ 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. [SOLVED] Macro to Delete rows containing Zero in a specific Column
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-03-2019, 08:38 AM
  2. Excel macro to match negative to positive and delete exactly matching row
    By jturnem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2017, 03:32 AM
  3. Macro to delete negative value and same positive value in a range
    By subrato312 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2017, 02:59 AM
  4. Macro to delete rows based on contents of specific column
    By WarZak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-31-2015, 04:58 PM
  5. Delete rows based on lower value than number specified , positive or negative values
    By LadyNicole in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 06-11-2013, 03:33 AM
  6. How to delete those rows which has same positive & negative value
    By joyharry in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 05-24-2013, 03:35 AM
  7. Replies: 3
    Last Post: 06-28-2011, 10:14 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