+ Reply to Thread
Results 1 to 21 of 21

Code to return date multiple criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Code to return date multiple criteria

    Hi all,

    I have no knowledge of VBA whatsoever and there is a function I need that is impossible to get on excel 2016.

    attached you can find my data set with 4 columns A to D. the order of the data in these columns will change except from the headers. I would really like to have a code that will generate columns F and G.

    column F is a consolidation of all unique numbers (loan ids) from column A (might include text and numbers i.e 1025A).

    column G returns a certain date. For each loan id the date would be the last "to be paid" date which represents the cumulative amount of payments that have not been covered untill this date.

    For example, loan number 1006 paid at 9 different dates and reached a total of 89,855. By the date 20/09/2021 this loan should have paid 90,000 and this amount has never been covered. the result I need is the date 20/09/2021.

    Another example, loan number 1006 paid at 11 different dates and reached a total of 121,000. by the date 10/03/2022 this loan should have paid 141,420 this amount has never been covered. the result I need is the date 10/03/2022.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Hello. I must respectfully disagree with your analyses. I mean:

    - 1004. The date should be July 20, 2021.

    - 1006. The date should be October 10, 2021.
    This last case seems to indicate that your analyzes are not by rigorous date but by "month and year". If so, then the date for 1006 would indeed be March 10, 2022.

    Comments?..

  3. #3
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    Hi,

    1004 - why do you think the date should be July 20, 2021? the date that i need is for sure Sep 20, 2021.

    1004 paid at 9 different dates and reached a total of 89,855. By the date 20/09/2021 this loan should have paid 90,000 and this amount has never been covered. thus, i need to return the date 20/09/2021.

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Quote Originally Posted by riiiiiicjjj View Post
    1004 - why do you think the date should be July 20, 2021? the date that i need is for sure Sep 20, 2021.
    Because as of July 20, 2001 you have:

    paid = 51500
    to be paid = 60000

  5. #5
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    thats right, but its not what i need.

    cumulative amount of payments made for 1004 = 89,855. last date of "to be paid" when a cumulative amount covered- 20/08/2021 75,000. last date not covered - 20/09/2021 90,000.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,365

    Re: Code to return date multiple criteria

    Hi riiiiicjjj,

    Perhaps a Pivot Table showing your data would help resolve your problem??
    Pivot of Payments and Dates.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  7. #7
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    thanks, unfortunately this does not give me the final data i need. i need to generate these dates

  8. #8
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Click on the button and analyze:
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    thank you for your time. result is not correct, when macro runs than 1004 returns 20/07/2021. should return 20/09/2021.
    the cumulative amount of payments made for 1004- 89,855. the last cumulative amount that has not covered is 90,000. the date in which 90,000 should have paid is 20/09/2021. this is the date i need

  10. #10
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    With the macro that I have attached in my last post I demonstrate that:

    - For 1006, the first date on which the balance becomes negative is taken.

    - But for 1004 the second date in which the balance becomes negative is taken.

    Put yourself in my place and note that your criteria is not uniform: do you understand me?...

  11. #11
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    i understand, the criteria should be:
    - take the cumulative amount of payments made
    - return the date of payment to be made which represents the most recent cumulative amount that is not covered - i.e. 90,000
    that means that the criteria is not the first negative balance

  12. #12
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Ahhh!... Then we change the order in which we have the data and that's it:

  13. #13
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Look at the following:
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    many thanks.
    in the attached file you can see that only 3 unique loan numbers are consolidated, could please tell me why? there are 9 unique in the data set. possible to include all in the code?
    Attached Files Attached Files

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Code to return date multiple criteria

    riiiicjj. Why did you attach the incorrect first sheet? You already have a formula that delas with the situation whhere everything is in a nice ordered sheet. The formula broke down when you presented a batch of disorganised data.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  16. #16
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    hi Glenn, i have attached an example that i think describes properly my needs. beyond excel really helps

  17. #17
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Quote Originally Posted by riiiiiicjjj View Post
    beyond excel really helps
    Did you look at post #13?...

  18. #18
    Registered User
    Join Date
    02-23-2022
    Location
    LA
    MS-Off Ver
    2016
    Posts
    51

    Re: Code to return date multiple criteria

    indeed, seems to work well. thank you so much for you time

  19. #19
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Code to return date multiple criteria

    Quote Originally Posted by riiiiiicjjj View Post
    indeed, seems to work well. thank you so much for you time
    Note that post #13 has not received any "Click" in reputation: Has the suggested idea really served you?
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

+ 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. Return a Date Multiple Criteria Help
    By riiiiiicjjj in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 11-22-2022, 11:41 AM
  2. Replies: 16
    Last Post: 10-13-2022, 05:45 AM
  3. Lookup and Return Date based on multiple criteria
    By ukama255 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-09-2019, 08:26 PM
  4. Return Max with multiple criteria including date - array?
    By helldizzle in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-13-2016, 09:10 PM
  5. VLOOKUP with multiple criteria. Return a specific date
    By gmazz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-14-2014, 08:03 PM
  6. VBA Code that will return max date based on multiple criteria
    By dubuquer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-19-2013, 02:13 AM
  7. Return Multiple Criteria Value with Greater, Less than and Date
    By exc4libur in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-04-2013, 04:44 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