Return Date range for Unique Payments

kevdragon1

New Member
Joined
Mar 8, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a data set made of 2 columns for each office.

Column A has the Payments.
Column B has the Date of the payments (1st of the month).

My goal is to have a summary (dates between which the payments will be made).

Here is an example :
PaymentDate
1000Dec 2020
1000Jan 2021
1500Feb 2021
1700Mar 2021
1700April 2021
1000May 2021
1000June 2021
0July 2021

The result I would expect is in an excel format :
PaymentStartEnd
1000Dec 2020Jan 2021
1500Feb 2021Feb 2021
1700Mar 2021April 2021
1000May 2021June 2021
0July 2021July 2021

The dates are always from small (earliest) to big (latest). The dates do not get duplicated.

The problem is the payments. In 90% of the case, the offices have bigger payments and the payments don't repeat.
My problem is that sometimes the payments will go (as shown above) like this: 1000$ for month 1, 2000$ for month 2 and 3, and then back down to 1000$ for month 4.

I tried coding a Macro with the UNIQUE formula for the payments and then using MIN and MAX to find the dates for each payment. That worked great until I realized that sometimes a payment will get repeated down the road...

Is there a formula that can help me? I think what needs to happen is for the Macro to understand that it needs to check each repeating payment row and return the dates and then do that for the whole column. But I have no idea how to do that.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I notice that you mention trying UNIQUE so I'm going to assume that you are using office 365 and not excel 2019 as shown on your profile.
Book1
ABCDEF
1PaymentDatePaymentStartEnd
21000Dec-201000Dec-20Jan-21
31000Jan-211500Feb-21Feb-21
41500Feb-211700Mar-21Apr-21
51700Mar-211000May-21Jun-21
61700Apr-210Jul-21Jul-21
71000May-21
81000Jun-21
90Jul-21
Sheet2
Cell Formulas
RangeFormula
D2:E6D2=FILTER(A2:B9,A2:A9<>A1:A8)
F2:F6F2=IFERROR(EOMONTH(E3,-1),E2)
Dynamic array formulas.
 
Upvote 0
Solution
I notice that you mention trying UNIQUE so I'm going to assume that you are using office 365 and not excel 2019 as shown on your profile.
Book1
ABCDEF
1PaymentDatePaymentStartEnd
21000Dec-201000Dec-20Jan-21
31000Jan-211500Feb-21Feb-21
41500Feb-211700Mar-21Apr-21
51700Mar-211000May-21Jun-21
61700Apr-210Jul-21Jul-21
71000May-21
81000Jun-21
90Jul-21
Sheet2
Cell Formulas
RangeFormula
D2:E6D2=FILTER(A2:B9,A2:A9<>A1:A8)
F2:F6F2=IFERROR(EOMONTH(E3,-1),E2)
Dynamic array formulas.
Hi,

Ah...I updated that, yes I am using 365.

Thank you for the fast response. Did you copy-paste the start dates? Is there a way to get them from a formula?

Edit: facepalm...the filter function returns the start date....let me see if this is working thx :)
 
Upvote 0
I notice that you mention trying UNIQUE so I'm going to assume that you are using office 365 and not excel 2019 as shown on your profile.
Book1
ABCDEF
1PaymentDatePaymentStartEnd
21000Dec-201000Dec-20Jan-21
31000Jan-211500Feb-21Feb-21
41500Feb-211700Mar-21Apr-21
51700Mar-211000May-21Jun-21
61700Apr-210Jul-21Jul-21
71000May-21
81000Jun-21
90Jul-21
Sheet2
Cell Formulas
RangeFormula
D2:E6D2=FILTER(A2:B9,A2:A9<>A1:A8)
F2:F6F2=IFERROR(EOMONTH(E3,-1),E2)
Dynamic array formulas.
Could you please explain this part of the formula in D2 : A2:A9<>A1:A8...You are saying return the column A that doesn't contain column A? I am a bit confused sorry. Why are you shifting by 1?
 
Upvote 0
By shifting 1 row it is looking for rows in column A that don't match the row above.

A2<>A1, A3<>A2, A4<>A3, etc..
 
Upvote 0
I wasn't able to make the end date formula spill due to the last row in the source table having a zero payment amount which has the same numeric value as the empty cell below it.
The mini sheet below has an end date formula that will spill but as you can see the final end date is missing. With a payment other than 0 in A9 the final end date shows correctly.
Book1
ABCDEF
1PaymentDatePaymentStartEnd
21000Dec-201000Dec-20Jan-21
31000Jan-211500Feb-21Feb-21
41500Feb-211700Mar-21Apr-21
51700Mar-211000May-21Jun-21
61700Apr-210Jul-21
71000May-21
81000Jun-21
90Jul-21
Sheet2
Cell Formulas
RangeFormula
D2:E6D2=FILTER(A2:B9,A2:A9<>A1:A8)
F2:F5F2=FILTER(B2:B9,A2:A9<>A3:A10)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,797
Members
448,994
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top