+ Reply to Thread
Results 1 to 18 of 18

Macro to delete rows where Values are oposite & Equal Col H

  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 Values are oposite & Equal Col H

    I have tried to write code that where values are opposite and equal eg 150 -150 in Col H and the account number is the same or if no account number, then those rows are to be deleted

    I cannot get it to do this

    It would be appreciated if someone could kindly amend my code or provide new code






    Please Login or Register  to view this content.

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    I have tried to write code
    that where values are opposite and equal eg 150 -150 in Col H and the account number is the same or if no account number, then those rows are to be deleted
    So what is it...
    Must it be deleted if no account number...And
    Must it be deleted if the Acc no's are the same and the balance is zero...Cancels each other out
    What if the balances cancel each other out and the Acc no's are not the same...

    I think you need to be more specific...
    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 Values are oposite & Equal Col H

    Hi Sintek


    I need the macro to do the following


    1) where there is no account number and values opposite and equal then those rows to be deleted
    2) Where account numbers are the same and values apposite & equal, then those rows are to be deleted
    3) Where balances cancel out but account numbers not the same then no action to be taken

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    So in your sample all remains the same...Nothing needs to get deleted...

  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 Values are oposite & Equal Col H

    My apologies Sintek


    I have uploaded a new sample workbook

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Try this...
    Please Login or Register  to view this content.
    Same...
    Please Login or Register  to view this content.
    Last edited by sintek; 10-06-2020 at 08:31 AM.

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Thanks Sintek

    Code works perfectly

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Glad I could assist...

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Hi Sintek


    I tested your code on additional sample date this morning and get run time error no cells were found and code below ae highlighted

    Please Login or Register  to view this content.

    Kindly check & amend your code


    thanks


    Howard

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    That is due to your file setup been different...this file has more than two criteria matches...
    i.e. AR01 has 6 entries...Code was written for two opposite entries only as per original sample and requirement...

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Thanks for letting me know

    I will amend your code just to delete values where the values are opposite & equal

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    I will amend your code just to delete values where the values are opposite & equal
    That will not be possible...Need a different code...don't have time this week...Will see if I can hop on board next week unless some else can solve for you...

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Thanks Sintek. No huge rush-Always appreciate the help on from you and others on this forum

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Not sure how big your dataset is...
    Please Login or Register  to view this content.

  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 Values are oposite & Equal Col H

    Hi Sintek

    Thanks for the help

    The dataset is not large (maximum rows 500)

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    K cool...that loop code will suffice...Not sure if the order of data is important...Did not bother with adjusting sort to original entry order...

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    order of data is not important

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

    Re: Macro to delete rows where Values are oposite & Equal Col H

    Thanks for rep +

+ 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 where sum of values sum to zero
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 05-28-2020, 03:50 PM
  2. Replies: 2
    Last Post: 09-11-2017, 03:42 PM
  3. VBA/Macro to delete cell values if equal to another cell
    By John Swift in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-30-2014, 04:37 AM
  4. [SOLVED] How to use a macro to remove rows whose values in column A equal to blank spaces?
    By billj in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-16-2014, 06:38 AM
  5. Replies: 5
    Last Post: 06-12-2014, 02:48 PM
  6. Delete rows with cell values equal to or greater than current week number
    By Pradeep M B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2013, 09:39 AM
  7. Macro to delete entire rows where O2:O does not equal a date
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2011, 10:37 PM

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