xlookup, vlookup, hlookup with and/if multiple criteria. Which do I use?

shina67

Board Regular
Joined
Sep 18, 2014
Messages
141
Hi All,

I have a problem with the below which I am hoping one of you genius people can help with.

From image 1 the cell B2 is dynamic to any day of the year. Cell F2 is also a drop down which has 16 catergories.

I need to be able to lookup in image 2 based on the 2 above criteria. As you can see in image 1 it clearly says that on 15th Feb there are 2 members of staff on holiday.
What I need is from image 2 to find out who them 2 members of Staff are.

If the date and Department changed it would need to find if anyone is on holiday from that department and on that date.

Is there a formula that would do this without the need of vba?

I am trying to build this dashboard and planner without the use of vba to try and broaden my formula knowledge.

I have come across some new formula that I haven't used before whilst building this but have come stuck on this part.

I hope what i am trying to achieve is explained properly. Any questions or help would be greatly recieved.

Thanks in advance.



Dashboard.JPG
Holiday Tracker.JPG
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You need an extra column to deal with the dynamic needs of each day.

Simply, put in an extra column, which you can hide if you wish, to show this formula: C22 = =IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="H",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="UA",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),""))
where C19 = today().

Instead of "H" and "UA" have them each in a cell and refer to that cell if you wish. Then do a count and whatever math you need in that cell.

If you want to take this one step further and do a report each day of who is on leave and who has UA on that day you can do a match, index offset in a separate location that will list those on holiday.

17​
BCDEFGHIJKLM
18​
find this->H
19​
28-11-23​
employees on holiday today
20​
matchindex
21​
Today?
27-11-23​
28-11-23​
22​
zak ellisUAHUA
3​
andrew wood
23​
andrew woodHUAH
4​
ayden windle
24​
ayden windleHH
C19 = today()
C21 = =IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="H",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="UA",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),""))
K22 =MATCH($L$18,OFFSET($C$21,K21,,1000),0)+K21
L22 =INDEX($B$21:$B$24,K22)
 
Upvote 0
You need an extra column to deal with the dynamic needs of each day.

Simply, put in an extra column, which you can hide if you wish, to show this formula: C22 = =IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="H",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="UA",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),""))
where C19 = today().

Instead of "H" and "UA" have them each in a cell and refer to that cell if you wish. Then do a count and whatever math you need in that cell.

If you want to take this one step further and do a report each day of who is on leave and who has UA on that day you can do a match, index offset in a separate location that will list those on holiday.

17​
BCDEFGHIJKLM
18​
find this->H
19​
28-11-23​
employees on holiday today
20​
matchindex
21​
Today?
27-11-23​
28-11-23​
22​
zak ellisUAHUA
3​
andrew wood
23​
andrew woodHUAH
4​
ayden windle
24​
ayden windleHH
C19 = today()
C21 = =IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="H",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),IF(HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE)="UA",HLOOKUP($C$19,$F$21:$G$24,ROW(A1)+1,FALSE),""))
K22 =MATCH($L$18,OFFSET($C$21,K21,,1000),0)+K21
L22 =INDEX($B$21:$B$24,K22)
Hi BrerRabbit,

Thanks for your reply.

When using the formula above and adapted for my sheets and cells I get #N/A returned.
I have adapted the above formula to be :-

=IF(HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$3:$NM$4,ROW(A1)+1,FALSE)="H",HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$7:$NM$999,ROW(A1)+1,FALSE),IF(HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$7:$NM$999,ROW(A1)+1,FALSE)="HH",HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$7:$NM$999,ROW(A1)+1,FALSE),""))

Also on the above formula's where does K21 refer to.

After getting a full list of who is on H or UA I could then use the FILTER formula to just display the Department of who is on H or UA.

I look forward to your reply.
 
Upvote 0
#n/a is bcuz there's no data to be retrieved. Use this:

=IF(HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$3:$NM$4,ROW(A1)+1,FALSE)="H",HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$7:$NM$999,ROW(A1)+1,FALSE),IF(HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$7:$NM$999,ROW(A1)+1,FALSE)="HH",HLOOKUP(Dashboard!$B$2,'Holiday Tracker'!$L$7:$NM$999,ROW(A1)+1,FALSE),""))

Instead of the match, go with filter as you correctly suggested, and try this:

17​
BCDEFGHIJKLM
18​
find this->HDeptblue
19​
Dept
28-11-23​
employees on holiday today from Dept blue
20​
21​
Today?
27-11-23​
28-11-23​
ayden windleblueH
22​
zak ellisblueUAHUA
23​
andrew woodGreenHUAH
24​
ayden windleblueHH

L3 = =FILTER(B22:D24,($C$22:$C$24=$O$18)*($D$22:$D$24=$M$18),"") giving both the dept and the absence type you requested.
 
Upvote 0
Hi BrerRabbit,

I am probably missing something so very simple but it has been a long couple of days. I cannot seem to get the above to work for me or I have not explained properly.

I have attached a couple more screenshots to hopefully explain a bit better.

So on the 'Dashboard' sheet (dashboard image attached) I am wanting to use the data in cells $B$2 & $F$2 as my criteria.

In the 'Holiday Tracker' sheet (Holiday Tracker image attached) I want to lookup the date from Dashboard!$B$2 & the department from Dashboard!$F$2 and return who is on Holiday.

So the returned values from the attached images should be Martin Leveridge & Paul Ian Hewitt.
If the date in Dashboard!$B$2 was changed to 13th February the returned values should be Kyle Young & Martin Leveridge.

If the department in Dashboard!$F$2 was changed to 'Bifolds' or any of the other 15 departments then the values returned from the attached images would be blank.

Hopefully I can adapt the formula then so I can see who is on Holiday (H or HH), who is on Sick (S & SS) & Unauthorised Absence (UA).
 

Attachments

  • Dashboard.JPG
    Dashboard.JPG
    28.4 KB · Views: 8
  • dashboard.JPG
    dashboard.JPG
    69.3 KB · Views: 8
  • Holiday Tracker.JPG
    Holiday Tracker.JPG
    199.5 KB · Views: 9
Upvote 0
Book1.xlsx
ABCDEFGHIACAD
1
2Wednesday, 14 February 2024Cut/Prep
3
4
5
6
7
8
9
Dashboard


Book1.xlsx
ABAQARASATAUAVAWAXAYAZBABBBCBDBEBFBG
1
2
3
401/02/202402/02/202403/02/202404/02/202405/02/202406/02/202407/02/202408/02/202409/02/202410/02/202411/02/202412/02/202413/02/202414/02/202415/02/202416/02/2024
5NameArea01020304050607080910111213141516
6ThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFri
7ASHLEY BAIRSTOWAdeco
8HERSCHEL LAKEAdeco
9PAUL CUNNINGHAMAdeco
10ADAM FLETCHERBifolds
11BRANDON ROBERTSONBifolds
12CHRISTOPHER PEARSONBifolds
13DANIEL JENNINGSBifolds
14DECLAN MILBURNBifolds
15DECLAN MCLAUGHLINBifolds
16GARY MADDOXBifolds
17GEOFFREY NEIL GREENWOODBifolds
18JAMIE MILLSBifolds
19JAMIE SHAWBifolds
20JOHN MARTIN FISHERBifolds
21JOHN MORRELLBifolds
22JOSHUA PICKERINGBifolds
23LOUIE WHITEBifolds
24MARIA NOEMI DE FREIT JOAOBifolds
25MARK CLEGGBifolds
26MARTIN JOHN WALKERBifolds
27NEIL LORIMERBifolds
28ROBERT MOUNTAINBifolds
29THEMBA DLAMINIBifolds
30JEAN WILLIAMSCleaner
31KODUA TWENEBOACleaner
32RUTH AMOAKOCleaner
33SARAH BILTONCleaner
34ALAN PHILIP VICKERSCut/Prep
35ALEX ALHASSANCut/Prep
36CALLUM SMITHCut/Prep
37DANIEL BRIGHAMCut/Prep
38DARREN JOSEPH SANDERSCut/Prep
39HARRY POWELLCut/Prep
40JOHN COPLAND MCDONALDCut/Prep
41JOHN DAVID MASSINGHAMCut/Prep
42JONATHON PAUL COWLINGCut/Prep
43KEITH SMITHCut/Prep
44KYLE YOUNGCut/PrepHUA
45MARTIN LEVERIDGECut/PrepHHHHHH
46PAUL IAN HEWITTCut/PrepSHH
47
48
49
Holiday Tracker
Cell Formulas
RangeFormula
AQ5:BF5AQ5=AQ4
AQ6:BF6AQ6=TEXT(AQ4,"DDD")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L7:BF46Cell Value="L"textNO
L7:BF46Cell Value="UA"textNO
L7:BF46Cell Value="SS"textNO
L7:BF46Cell Value="S"textNO
L7:BF46Cell Value>0textNO
L7:BF46Cell Value="HH"textNO
L7:BF46Cell Value="H"textNO
L7:BF46,L5:BF5,L6:AO6,AQ6:BF6Expression=L$6="Sun"textNO
L5:BF5,L6:AO6,AQ6:BF6,L7:BF46Expression=L$6="Sat"textNO
 
Upvote 0
Assuming you are putting the formula on the Dashboard, does this work for you ?

Excel Formula:
=LET(colDay,INDEX('Holiday Tracker'!$L$7:$BF$999,0,MATCH($B$2,('Holiday Tracker'!$L$4:$NM$4))),
FILTER('Holiday Tracker'!$A$7:$A$999,((colDay="H")+(colDay="HH"))*('Holiday Tracker'!$B$7:$B$999=$F$2)))
 
Upvote 0
I'm going to go back to the beginning here:

1. Insert the extra column to catch the type of absence. As there is only going to be one type of absence, we'll do just a simple catch
=IF(HLOOKUP($C$2,$D$5:$F$13,ROW(A1)+1,FALSE)<>0,HLOOKUP($C$2,$D$5:$F$13,ROW(A1)+1,FALSE),"")
2. Number of employees for the Department is countif(dept range from holiday tracker tab, F2).
3. Number of Absences. if B14 is where this is: countifs(dept range from holiday tracker tab, F2, today? column, date cell) will look like:
=COUNTIFS(B6:B13,O2,C6:C13,K9)
4. Then divide no of absences / no of employees and format as percentage.

The filter, depending on what version of excel you have, can give a mini report under your dashboard of who is doing what absences, based on the cells in your dashboard.
 
Upvote 0
I'm going to go back to the beginning here:

1. Insert the extra column to catch the type of absence. As there is only going to be one type of absence, we'll do just a simple catch
=IF(HLOOKUP($C$2,$D$5:$F$13,ROW(A1)+1,FALSE)<>0,HLOOKUP($C$2,$D$5:$F$13,ROW(A1)+1,FALSE),"")
2. Number of employees for the Department is countif(dept range from holiday tracker tab, F2).
3. Number of Absences. if B14 is where this is: countifs(dept range from holiday tracker tab, F2, today? column, date cell) will look like:
=COUNTIFS(B6:B13,O2,C6:C13,K9)
4. Then divide no of absences / no of employees and format as percentage.

The filter, depending on what version of excel you have, can give a mini report under your dashboard of who is doing what absences, based on the cells in your dashboard.
you can then also use data validation to use the one dashboard for the various types of absences as well as the different dashboards. The mini report ie the filter will update accordingly.
 
Upvote 0
=LET(colDay,INDEX('Holiday Tracker'!$L$7:$BF$999,0,MATCH($B$2,('Holiday Tracker'!$L$4:$NM$4))),
FILTER('Holiday Tracker'!$A$7:$A$999,((colDay="H")+(colDay="HH"))*('Holiday Tracker'!$B$7:$B$999=$F$2)))

Thanks Alex Blakenburg.

That works absolutely brilliantly and gives the results wanted.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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