Excel Formula for checking next closest date/year in a raw data

amanphilip

New Member
Joined
Jul 4, 2023
Messages
18
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello to All!

Hope you are having a great day! I am trying to figure out on how to create a checker column where in it will 2 columns. The logic i am trying to achieve is to check Contract # then check the next closest year on Year column and put 1 on it.

Here's the sample screenshot of what i am trying to achieve:

1709083325809.png



Final Output needed on the report excluding the checker column:

1709083388268.png


I have searched the internet but i cannot find any thread has the same with the conditions i needed.

Thank you so much in advance. Regards.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You can try this:
Book1
ABCDE
1CONTRACT IDYear
25465465465202554654654652025
354654654652026888798132027
454654654652027
554654654652028
654654654652029
754654654652030
8888798132027
9888798132028
10888798132029
11888798132030
12888798132031
Sheet5
Cell Formulas
RangeFormula
D2:D3D2=UNIQUE(A2:A12)
E2:E3E2=LET(Cntrs,A2:A12,Yrs,$B$2:$B$12,Cntr,D2,Yr,D3,myr,MINIFS(Yrs,Cntrs,Cntr),myr)
Dynamic array formulas.
 
Upvote 1
Hi awoohaw,

Thank you for your quick reply. My apologies as i forgot to mention that my excel is 2019 and doesn't support dynamic array formulas. Do you think this is possible via vba?
 
Upvote 0
try this. Its pretty clunky, but it seems to work.


Book1
ABCDE
1CONTRACT IDYear
254654654652025888798132027
35465465465202654654654652025
454654654652027
554654654652028
654654654652029
754654654652030 
8888798132027 
9888798132028 
10888798132029 
11888798132030 
12888798132031 
Sheet5
Cell Formulas
RangeFormula
D2:E3D2= IF(ROWS($A$2:$A2)>SUM(--(IFERROR( ($A$2:$A$12)/($A$1:$A$11),0 )<>1)),"", INDEX($A$2:$B$12,LARGE((IFERROR( ($A$2:$A$12)/($A$1:$A$11),0 )<>1)*(ROW($A$2:$A$12)-ROW($A$1)),ROWS($A$2:$A2)),0))
E7:E12E7= IF(ROWS($A$2:A7)>SUM((IFERROR(($A$2:$A$12)/($A$1:$A$11),0)<>1)*1),"", INDEX($B$2:$B$11,LARGE((IFERROR($A$2:$A$12/$A$1:$A$11,0)<>1)*(ROW($A$2:$A$12)-ROW($A$1)), SUM((IFERROR(($A$2:$A$12)/($A$1:$A$11),0)<>1)*1))))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi awoohaw,

I tried to apply the formulas, the first column is fine however the 2nd one is showing same results. Sorry i am not familiar with array formulas, did i miss something?

And also can you help me tweak the formula to choose the next closest year based on today's date/ local date of the computer?

1709098195702.png
 
Upvote 0
Well, intead of trying to capture both columns in one formula, try to break it up and get one at a time.
Again, use CNTL-SHFT_ENTR (CSE) to commit the formula if it doesn't work without it. (It may work in 2019)

Also, enter the whole mini worksheet I have below on a brand new worksheet before you put it in your workbook and alter it.
This is to be sure that the formula works as expected with the data as I've set it up in your environment.

1. Paste into fresh worksheet.
NOTE: you may need to edit the braces out of the formulas in D2 and E2, and then recommit the formula with CSE.
2. Confirm this works, add new data as you see fit in columns A and B. Drag the formula from D2:E2 down as far as necessary.
3. When satisfied with the formula, put it in your worksheet.


Book1
ABCDE
1CONTRACT IDYear
254654654652025888798132027
35465465465202654654654652025
454654654652027  
554654654652028  
654654654652029  
754654654652030  
8888798132027  
9888798132028  
10888798132029  
11888798132030  
12888798132031  
Sheet1
Cell Formulas
RangeFormula
D2:D12D2= IF(ROWS($A$2:$A2)>SUM(--(IFERROR( ($A$2:$A$12)/($A$1:$A$11),0 )<>1)),"", INDEX($A$2:$B$12,LARGE((IFERROR( ($A$2:$A$12)/($A$1:$A$11),0 )<>1)*(ROW($A$2:$A$12)-ROW($A$1)),ROWS($A$2:$A2)),1))
E2:E12E2= IF(ROWS($A$2:$A2)>SUM(--(IFERROR( ($A$2:$A$12)/($A$1:$A$11),0 )<>1)),"", INDEX($A$2:$B$12,LARGE((IFERROR( ($A$2:$A$12)/($A$1:$A$11),0 )<>1)*(ROW($A$2:$A$12)-ROW($A$1)),ROWS($A$2:$A2)),2))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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