Leave roster with duplicate names and multiple date ranges

harleythecav

New Member
Joined
May 18, 2020
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hello forum - not sure what is possible so any assistance with the below question appreciated.

I have 2 worksheets in a workbook: Sheet 1 is my raw data set and Sheet 2 is the leave roster I'm creating.

Sheet 1 (raw data) has:
Column D = names (duplicate names exist)
Column F = Status (6 options: Approved, Unapproved, Cancelled, Declined, Deleted, Errored)
Column G = start date
Column H = end date

Sheet 2 (leave roster) has:
Column B = names (lists of names from sheet 1 with no duplicates using index/match formula to create list of unique values - this starts at row 13, header row 12)
Row 12 is the dates starting with =today() in Column F (and this continues across the row for 365 columns to capture 1 year using +1)

Ideally what I would like to do is:
Bring back the Status from Column F in Sheet 1 into Sheet 2, starting at F13 (then below and across for all names and dates) based on if -
1) the date in Sheet 2 Row 12 (starting with Column F) is equal to or between the date range of Columns G and H in Sheet 1
and
2) the name in Sheet 2 Column B (starting with Row 13) matches the name in Sheet 1 Column D (keeping in mind that Sheet 1 has duplicate names and Sheet 2 uses a formula to create a unique list of names that will change when the raw data in Sheet 1 is updated)

Ideally I would like to capture the Status as an abbreviation if possible (Approved = A, Unapproved = U, Cancelled = Ca etc) however if only Approved and Unapproved are possible this would be enough to help with blank or "X" where no data point exists.

I know how to achieve this is there are no duplicates names in Sheet 1 and also if I use an interim table as a work around but I don't want to do that if I can avoid it.
Is what I want to achieve possible?

Sheet 1 (Range A3 to H8):
Mgr NameMgr DescEmployee CodeEmployee NameRequest LengthStatusStart DateEnd Date
1Name 1Approved30/03/202030/03/2020
2Name 1Deleted6/04/202017/04/2020
3Name 2Unapproved24/04/202015/05/2020
4Name 3Approved14/04/202017/04/2020
5Name 4Cancelled26/03/202027/03/2020


Sheet 2 (Range B12 to J17) - illustrative example only of what I am trying to achieve, does not directly match the data example shown above:
Employee NamePayroll #Mgr NameMgr Desc19-May20-May21-May22-May23-May
Name 11--XXAAA
Name 23--XXXXX
Name 34--UXXXX
Name 45--XXCaXX
Name 57--XDelXXX
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi HarleyTheCav,

I've changed some date ranges to get better test data, added a lookup table to decode the Status into a Display Code. Beware of using my test data as the dates will be in US format.

HarleyTheCav.xlsx
ABCDEFGHIJKLM
3Mgr NameMgr DescEmployee CodeEmployee NameRequest LengthStatusStart DateEnd DateStatusDisplay Code
41Name 1Approved30-Mar-2030-Mar-20ApprovedA
52Name 1Deleted06-Apr-2017-Apr-20UnapprovedU
63Name 2Unapproved24-Apr-2022-May-20CancelledCa
74Name 3Approved20-May-2021-May-20DeclinedDec
85Name 4Cancelled22-May-2023-May-20DeletedDel
97Name 5Declined20-May-2020-May-20ErroredErr
10NoneX
Sheet1


Here's Sheet2 with the formulae.

HarleyTheCav.xlsx
BCDEFGHIJ
12Employee NamePayroll #Mgr NameMgr Desc19-May-2020-May-2021-May-2022-May-2023-May-20
13Name 11--XXXXX
14Name 23--UUUUX
15Name 34--XAAXX
16Name 45--XXXCaCa
17Name 57--XDecXXX
Sheet2
Cell Formulas
RangeFormula
F12F12=TODAY()
G12:J12G12=F12+1
F13:J17F13=IF(B13="","",INDEX(Sheet1!$M$4:$M$10,MATCH(IFERROR(INDEX(Sheet1!$F$4:$F$11,AGGREGATE(15,6,ROW(Sheet1!$D$4:$D$11)-ROW(Sheet1!$D$3)/((Sheet1!$G$4:$G$11<=F$12)*(Sheet1!$H$4:$H$11>=F$12)*(Sheet1!$D$4:$D$11=$B13)),1)),"None"),Sheet1!$L$4:$L$10,0)))
B13:B16B13=INDEX(Sheet1!$D$4:$D$11,MATCH(0,INDEX(COUNTIF($B$12:$B12,Sheet1!$D$4:$D$11),),0))&""
C13:C17C13=IFERROR(INDEX(Sheet1!$C$4:$C$11,MATCH(B13,Sheet1!$D$4:$D$11,0)),"")
 
Upvote 0
This solution worked perfectly, thank you so much for your prompt response!
Also, the formula you used for the unique list of names had a slight variation to the one I was using so I now no longer get a random 0 at the end of my list which is a bonus
Sincerely appreciate your time and expertise :)
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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