+ Reply to Thread
Results 1 to 10 of 10

Need to find a negative amount and match it to the positve amount based on Acct# and Date

  1. #1
    Registered User
    Join Date
    05-26-2015
    Location
    Rolla, MO
    MS-Off Ver
    2010
    Posts
    6

    Post Need to find a negative amount and match it to the positve amount based on Acct# and Date

    I have a spreadsheet where I need to create VBA code to delete the accounts that have a transaction that has been written off so in the spreadsheet it shows the listing twice once with a positive number and then with a negative number. These numbers are not always by each other, there may be several transactions between them. I have the code that is now marking them for delete but what it is doing is finding the first negative amount and then matching to the first positive amount that matches it. I need it to first check to see if the account number and date of transactions match and then if it does mark these two for deletion. Here is an example of the file.

    AccountNumber ServiceDateTime Amount Mark for Deletion
    12345617 1/1/2015 -521.56 Delete
    12345617 1/1/2015 28.50
    12345617 1/1/2015 521.56 Delete
    12345617 1/1/2015 521.56
    12345617 1/3/2015 18.57
    12345617 1/5/2015 19.25
    12345617 1/6/2015 1510.15
    12345617 1/6/2015 -49.95 Delete
    12345617 1/6/2015 49.95 Delete
    12345617 1/10/2015 295.68
    12345617 1/11/2015 19.98
    12345617 1/12/2015 2508.25


    Current Code:
    Please Login or Register  to view this content.
    Any help greatly appreciated.


    Moderator Note: I have added code tags for you. Please read forum rules and comply in the future.
    Last edited by alansidman; 01-06-2016 at 09:49 PM. Reason: code tags added

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    Submit an example worksheet with data so we have something to test on.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Registered User
    Join Date
    05-26-2015
    Location
    Rolla, MO
    MS-Off Ver
    2010
    Posts
    6

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    Here it is
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    Just out of curiosity, will the rows that need to be deleted always say "Delete" in column D? Or is that just put there to better describe which rows you want deleted?

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

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    Try
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    There is a good chance I might have overthought this:

    Please Login or Register  to view this content.

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

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    Quote Originally Posted by sbrandhorst View Post
    I need it to first check to see if the account number and date of transactions match and then if it does mark these two for deletion.
    Missed that part.
    Change to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-26-2015
    Location
    Rolla, MO
    MS-Off Ver
    2010
    Posts
    6

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    I added thirty lines of data and this code freezes my excel up.

  9. #9
    Registered User
    Join Date
    05-26-2015
    Location
    Rolla, MO
    MS-Off Ver
    2010
    Posts
    6

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    Thanks jindon it worked. You are amazing

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

    Re: Need to find a negative amount and match it to the positve amount based on Acct# and D

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] Loop through tabs and return date and amount when amount is present
    By rs1aj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2015, 04:19 PM
  2. Replies: 2
    Last Post: 11-21-2014, 09:35 AM
  3. [SOLVED] Update Amount after Match the Amount
    By shyampanda in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-14-2014, 06:50 AM
  4. Replies: 2
    Last Post: 04-28-2013, 02:23 AM
  5. How to match Date and Amount from Sheet1 to Sheet2 with the same Date and Amount?
    By ims0phie in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-23-2013, 06:51 AM
  6. [SOLVED] In pivot match vertical row amount with the horizontal column -amount and highlight that
    By Goku in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2013, 02:04 AM
  7. How can I calculate amount of time left based on amount spent?
    By KLD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-23-2006, 11:25 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