+ Reply to Thread
Results 1 to 25 of 25

Deleting Correlating Positive and Negative Numbers based on Criteria

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Deleting Correlating Positive and Negative Numbers based on Criteria

    Dear All,

    I have a large spreadsheet that i am trying to cleanup. it contains thousands of rows where it shows a positive transaction with a matching negative transaction.

    what i want is to delete that matching transaction based on following condition;

    if matching postive and negative transaction alongwith amount is reconcile with ACCOUNT NO then both entries should be deleted.

    this is previously solved with VBA but i am unable to modify according to my need.

    i have attached the sheet for ease of reference.

    thanx and cheers.
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Hi,

    In your attachment, you indicate that the following pair should be deleted:

    900138163 PROFESSIONAL FEES DR. SHAZIA SHAFIQUE -1.00 -770.00
    900136073 PROFESSIONAL FEES DR. SHAZIA SHAFIQUE -1.00 -770.00

    though this does not match your criterion that the Account Numbers should match.

    Please clarify.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    yes thats true and you are right.......... i am sorry the pair matching is row no 7 & 8

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Hi,

    But now there are three matching that Account No. I assume that one of the positive lines remains and one is deleted, but does it matter which one?

    900138163 PROFESSIONAL FEES DR. SHAZIA SHAFIQUE -1.00 -770.00
    900138163 PROFESSIONAL FEES DR. SHAZIA SHAFIQUE -1.00 -770.00
    900138163 PROFESSIONAL FEES DR. SHAZIA SHAFIQUE -1.00 -770.00

    Regards

  5. #5
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    yes your assumption is correct, it does not matter.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Hi,

    One more question: is the corresponding negative transaction always on the row immediately above or below that of the positive transaction?

    Regards

  7. #7
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    no it can be anywhere in the rows of around 1000.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Hi,

    Place this formula in cell E2 of you sheet and copy down as required:

    =IF((SUMPRODUCT(($A$2:$A$1000=A2)*($C$2:$C$1000=-C2)*($D$2:$D$1000=-D2))>0)*(SUMPRODUCT(($A$2:$A2=A2)*($C$2:$C2=C2)*($D$2:$D2=D2))=1),"DELETE","")

    Amend the range references to suit your needs. Then filter on this column for DELETE and delete those rows.

    Suggest you do some spot tests on this formula before going ahead and performing the actual delete.

    Regards

  9. #9
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    great brother......it works.

    thanx alot.

    cheers.

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Glad I could help. Best of luck with it.

  11. #11
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Dear XOR LX,
    i need your help once again the formula you suggested was working great but unfortunately this month i have a change in condition of which result is misleading, so this this ok but can you please help to add another condition of PHYSICAIN ID coloum E.(File Attached)

    thanx in advance.

    and sorry guys i have update the solved thread i dont know weather it is correct or not.

    Regards
    Attached Files Attached Files

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Hi,

    You have not clarified what this extra condition on Column E is.

    Regards

  13. #13
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    actually this is another criteria which it needs to be checked. just like account no. coloum A

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    You mean that the formula should only apply to cases where there is "SHME" in column E?

    Regards

  15. #15
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    yes where there is "SHME" ALSO

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Sorry - what do you mean by "ALSO"? I asked you whether it was to apply ONLY to cases where there is "SHME" in column E?

    Please clarify.

    Regards

  17. #17
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Dear Xor,
    YES i have written also because ACCOUNT NO (coloum A) alongwith PHYSICIAN ID (coloum E) these both should also match.

  18. #18
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Sorry, but it's still not clear whether you mean that records should only be considered for deletion if PHYSICIAN ID is "SHME" (you don't have any other type in your attached) OR whether the formula should be looking at cases in which the PHYSICIAN ID is the same (as currently applies to column A).

    Regards

  19. #19
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Dear Xor,
    I think i have to share a real example to help you understand;

    Untitled.jpg

  20. #20
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    as you will notice from the attachment that in coloum completeness the DELETE option is showing on the records where PHYSICIAN ID is not same. so finally the records of (PHYSICIAN ID) of AJMK should be deleted rather one record of AJMK & one of HLOH.

  21. #21
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    I'm afraid that doesn't help either: the two marked as "DELETE" in the COMPLETENESS column have different entries in the PHYSICIAN ID column, which would seem to contradict what you stated earlier (that the PHYSICIAN ID entries for those to be deleted should be the same).

    Edit: just seen your last post. Now I understand. One moment, please.

    Regards

  22. #22
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Dear XOR,
    Actually this is derived from the formula you suggested earlier, this is the example of record which i said was misleading this is just an example so to correct this error i request for your help.

  23. #23
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Hi,

    Change your formula in row 2 to:

    =IF((SUMPRODUCT(($A$2:$A$1000=A2)*($C$2:$C$1000=-C2)*($D$2:$D$1000=-D2)*($E$2:$E$1000=E2))>0)*(SUMPRODUCT(($A$2:$A2=A2)*($C$2:$C2=C2)*($D$2:$D2=D2)*($E$2:$E2=E2))=1),"DELETE","")

    and copy down as required. Please let me know if that solves the issue.

    Regards

  24. #24
    Registered User
    Join Date
    06-13-2012
    Location
    pakistan, sindh
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    Dear XOR,
    Finally we reach to a conclusion and i am really thankfull to you for all your support i really took your time and thanx alooooooot for your time and help..

    appreciated your patient and responses.

    thanx alooooooooot brother.

  25. #25
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Deleting Correlating Positive and Negative Numbers based on Criteria

    You're welcome.

+ 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