Array formula to list data if MONTH and DAY fall between two dates

SevenOut

Board Regular
Joined
Jan 7, 2020
Messages
82
Office Version
  1. 2013
Platform
  1. Windows
I have a workbook with two worksheets.
Sheet1 has a beginning date in D3 and an ending date in J3. (Schedule starting with Sat and ending with Fri).
Sheet2 has a list of birthdates. NAMES are A3:A47 and BIRTHDATES are B3:B47

So, my previous experience I've managed to work an array formula that would list the names and dates of birthdays for the current month. I'm having difficulty however adjusting the formula to find the names/dates if the month and day of Sheet2!B3:B47 fall between Sheet1!D3 and Sheet1!J3.

VBA Code:
=IFERROR(INDEX($A$3:$A$47,SMALL(IF(MONTH($B$3:$B$47)=MONTH(Sheet1!$D$3),ROW($A$3:$A$47)-ROW($A$3)+1),ROWS($1:1))),"")
This formula for example, will only return data for the month of date in Sheet1!D3.

I do hope my explanation is clear, an example sheet can be worked up if needed.
 
That is currently how the dates are set up... E3 =D3+1, F3= E3+1 and so on.
That formula was already on your sheet. The xl2bb tool put it there.
I just wanted to show the dates from 26dic2020 to 1ene2021 and you see how the formula on sheet2 already works for different years.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I appreciate your patience DanteAmor, I'm still trying to apply the formula. So far, incorrect or blank results.
Could you explain the first INDEX range of $A$1:$A$39? And the last reference of "-ROW($B$2)
My date formats are currently mm/dd/yy, would that affect what the formula reads?
 
Upvote 0
INDEX more than the range of data to be specific. Sometimes I feel like I need Google Translator for excel speak.
 
Upvote 0
Sorry for that, my formula must be in all cells from E3 to E39.
Then copy the formula into cell E3
Select cells from E3 and up to E39.
Pres F2 key.
Now press Control+Shift+Enter.

Book1
ABCDEF
1
2NameDateNameDate
3Name 101/01/1997Name 705/02/1974
4Name 202/01/1950Name 805/02/1965
5Name 314/01/1989  
6Name 421/01/1998  
7Name 527/01/1973  
8Name 628/01/1994  
9Name 705/02/1974  
10Name 805/02/1965  
11Name 927/03/1989  
12Name 1029/03/1997  
Sheet2
Cell Formulas
RangeFormula
E3:E12E3{=IFERROR(INDEX($A$1:$A$39, SMALL(IF(((DATE(YEAR(Sheet1!$D$3),MONTH($B$3:$B$39),DAY($B$3:$B$39))>=Sheet1!D3)*(DATE(YEAR(Sheet1!$D$3),MONTH($B$3:$B$39),DAY($B$3:$B$39))<=MAX((YEAR(Sheet1!$D$3:$J$3)=YEAR(Sheet1!$D$3))*(Sheet1!$D$3:$J$3))))+((DATE(YEAR(Sheet1!$J$3),MONTH($B$3:$B$39),DAY($B$3:$B$39))>=MIN((IF(YEAR(Sheet1!$D$3:$J$3)=YEAR(Sheet1!$J$3),Sheet1!$D$3:$J$3))))*(DATE(YEAR(Sheet1!$J$3),MONTH($B$3:$B$39),DAY($B$3:$B$39))<=Sheet1!$J$3)), ROW()),ROW()-ROW($B$2))),"")}
F3:F12F3=IFERROR(VLOOKUP(E3,$A$3:$B$39,2,0),"")
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.


_________________________________________________________________________________________________________
Check in my test file.
 
Upvote 0
Okay okay, I was extending the array down maybe 10 rows, once I extended it to match the source range, it worked! I'd be lying if I said I understood it. Hope I can pay it forward helping somebody else down the road. I do want to thank everyone who've contributed to solving my question!!
 
Upvote 0
Im glad to help you. Thanks for the feedback.
 
Upvote 0
Here are some more options you might like to consider. They do not require the Ctrl+Shift+Enter confirmation and are a bit shorter as well.

I have made D3 and J3 in 'Schedule' named ranges (though we could just as easily use the cell references if you don't want to do this).
D3 is named D_Start
J3 is named D_End

SevenOut Workbook.xlsx
ABCDEFGHIJ
1
2
328-Dec29-Dec30-Dec31-Dec1-Jan2-Jan3-Jan
4Lead SupervisorSATSUNMONTUEWEDTHUFRI
Schedule


Below, the formulas in columns E:F list the results oldest person to youngest. H:I list them in the order they appear in columns A:B, so choose whatever suits you best.
I have hidden a majority of the rows to keep the screen shot smaller.

SevenOut Workbook.xlsx
ABCDEFGHI
1
2NameDateNameDateNameDate
3Name 11/1/97Name 22/1/50Name 11/1/97
4Name 22/1/50Name 3731/12/65Name 22/1/50
5Name 314/1/89Name 3628/12/82Name 3628/12/82
6Name 421/1/98Name 11/1/97Name 3731/12/65
7Name 527/1/73    
8Name 628/1/94    
36Name 344/12/91    
37Name 3513/12/85    
38Name 3628/12/82    
39Name 3731/12/65    
Birthdays
Cell Formulas
RangeFormula
E3:E8,E36:E39E3=IF(F3="","",INDEX(A:A,AGGREGATE(15,6,ROW(A$3:A$39)/(B$3:B$39=F3),COUNTIF(F$3:F3,F3))))
F3:F8,F36:F39F3=IFERROR(AGGREGATE(15,6,B$3:B$39/(((DATE(YEAR(D_Start),MONTH(B$3:B$39),DAY(B$3:B$39))>=D_Start)+(DATE(YEAR(D_Start),MONTH(B$3:B$39),DAY(B$3:B$39))<=D_End)=2)+((DATE(YEAR(D_End),MONTH(B$3:B$39),DAY(B$3:B$39))>=D_Start)+(DATE(YEAR(D_End),MONTH(B$3:B$39),DAY(B$3:B$39))<=D_End)=2)>0),ROWS(F$3:F3)),"")
H3:H8,H36:H39H3=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(A$3:A$39)/(((DATE(YEAR(D_Start),MONTH(B$3:B$39),DAY(B$3:B$39))>=D_Start)+(DATE(YEAR(D_Start),MONTH(B$3:B$39),DAY(B$3:B$39))<=D_End)=2)+((DATE(YEAR(D_End),MONTH(B$3:B$39),DAY(B$3:B$39))>=D_Start)+(DATE(YEAR(D_End),MONTH(B$3:B$39),DAY(B$3:B$39))<=D_End)=2)>0),ROWS(H$3:H3))),"")
I3:I8,I36:I39I3=IF(H3="","",VLOOKUP(H3,A$3:B$39,2,0))
Named Ranges
NameRefers ToCells
D_End=Schedule!$J$3H3:H8, H36:H39, F3:F8, F36:F39
D_Start=Schedule!$D$3H3:H8, H36:H39, F3:F8, F36:F39
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,228
Members
449,303
Latest member
grantrob

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