Formula to find date and return column number

jc352

Board Regular
Joined
Aug 13, 2008
Messages
139
Office Version
  1. 365
Platform
  1. Windows
I have a roster of employees and the dates they have requested off. The employee name is in column A, their location is in column B and their requested time off will either be in C through E (PTO), F through J (PH) or K through P (DH) depending on the entitlement time used. For simplicity this information will be on Test. On sheet 2 i have a calendar that i would like this information displayed on. On sheet 2 the year is in A1, the month (spelled out) is in A2 and the day is in C4. I am looking for a formula that will provide the employee name, location and type of entitlement used (PTO, PH or DH) for that date. This inforation would be displayed in cells A5, A6, A7, A8 and A9.

Here is the formula i currently have, which i am not able to get to indicate the correct entitlement. It just goes with the first item found when pulled down.

Current formula:

=IFERROR(INDEX(Test!$A$3:$A$45,SMALL(IF(DATE($A$1,MONTH(DATEVALUE($A$2&"1")),$C$4)=Test!$C$3:$P$45,ROW(Test!$C$3:$P$45)-ROW(Test!$A$3)+1),ROW(1:1)))&" - "&INDEX(Test!$B$3:$B$45,SMALL(IF(DATE($A$1,MONTH(DATEVALUE($A$2&"1")),$C$4)=Test!$C$3:$P$45,ROW(Test!$C$3:$P$45)-ROW(Test!$B$3)+1),ROW(1:1)))&" "&IF(AGGREGATE(15,6,COLUMN(Test!$C$3:$P$45)/(Test!$C$3:$P$45=DATE($A$1,MONTH(DATEVALUE($A$2&1)),$C$4)),1)<4,"(PTO)",IF(AND(AGGREGATE(15,6,COLUMN(Test!$C$3:$P$45)/(Test!$C$3:$P$45=DATE($A$1,MONTH(DATEVALUE($A$2&1)),$C$4)),1)>3,AGGREGATE(15,6,COLUMN(Test!$C$3:$P$45)/(Test!$C$3:$P$45=DATE($A$1,MONTH(DATEVALUE($A$2&1)),$C$4)),1)<9),"(PH)","(DH)")),"")

I appreciate any help that can be offered.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Rather than describe your problem. I find it's faster to get a solution by posting a sample sheet using XL2BB and updating your profile to let people know what Excel version you're using.
 
Upvote 0
Sheet with infomation for formula on calendar sheet.

Employee NameLocationPTOPTO2PTO3PHPH2PH3PH4PH5DHDH2DH3DH4DH5DH6
BillOXN7/1/2024
JackOXN
SueOXN7/1/2024
DaveOXN
GarySBA
AustinSBA
BobbySBA7/1/2024
EdgarSBA
SamSBA
HectorSBA

Calendar Sheet

2024 Vacation Calendar - Test.xlsm
ABCDEFGHIJKLMNO
12024
2July
3MondayTuesdayWednesdayThursdayFridaySaturdaySunday
41234567
5Bill - OXN (PH)
6Sue - OXN (PH)
7Bobby - SBA (PH)
8 
9 
10
Sheet 2
Cell Formulas
RangeFormula
A2A2=TEXT(DATE(A1,7,1),"mmmm")
C4C4=IF(P1=2,1,"")
E4E4=IF(C4<>"",C4+1,IF($P$1=3,1,""))
G4G4=IF(E4<>"",E4+1,IF($P$1=4,1,""))
I4I4=IF(G4<>"",G4+1,IF($P$1=5,1,""))
K4K4=IF(I4<>"",I4+1,IF($P$1=6,1,""))
M4M4=IF(K4<>"",K4+1,IF($P$1=7,1,""))
O4O4=IF(M4<>"",M4+1,IF($P$1=1,1,""))
A5:A9A5=IFERROR(INDEX(Test!$A$3:$A$45,SMALL(IF(DATE($A$1,MONTH(DATEVALUE($A$2&"1")),$C$4)=Test!$C$3:$P$45,ROW(Test!$C$3:$P$45)-ROW(Test!$A$3)+1),ROW(1:1)))&" - "&INDEX(Test!$B$3:$B$45,SMALL(IF(DATE($A$1,MONTH(DATEVALUE($A$2&"1")),$C$4)=Test!$C$3:$P$45,ROW(Test!$C$3:$P$45)-ROW(Test!$B$3)+1),ROW(1:1)))&" "&IF(AGGREGATE(15,6,COLUMN(Test!$C$3:$P$45)/(Test!$C$3:$P$45=DATE($A$1,MONTH(DATEVALUE($A$2&1)),$C$4)),1)<4,"(PH)",IF(AND(AGGREGATE(15,6,COLUMN(Test!$C$3:$P$45)/(Test!$C$3:$P$45=DATE($A$1,MONTH(DATEVALUE($A$2&1)),$C$4)),1)>3,AGGREGATE(15,6,COLUMN(Test!$C$3:$P$45)/(Test!$C$3:$P$45=DATE($A$1,MONTH(DATEVALUE($A$2&1)),$C$4)),1)<36),"(PTO)","(DH)")),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C4,E4,G4,I4,K4,M4,O4Celldoes not contain a blank value textNO
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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