Finding cell based on a dropdown - using INDEX function

LucieLiskova

New Member
Joined
Jan 19, 2017
Messages
17
Hi,

I'm working on two different sheets - the Payroll File 2023 (picture 1), cell B8 will change based on A5 (dropdown list - showing working weeks), taking information from the Construction - Payroll Hrs 2023 (picture 2), starting with cell AK9 (54.00 in TOTAL column). This value will change each time, depending on the week - weeks are displayed in line 5. So if I select week 19 in Payroll File, I should get number 39.5 in total (BM9 - Construction payroll sheet). I am using the below formula but I have a feeling I've set it up for searching the info vertically rather than horizontally.

{IFERROR(INDEX('[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!$J$9:$AK$9,SMALL(IF('[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!$J$5:$DR$5=A5,ROW('[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!$J$9:$AK$9)-MIN(ROW('[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!$J$9:$AK$9))+1),COLUMNS(A5:A5))),"")}

Any help much appreciated.

Thank you.
Lucie.
 

Attachments

  • Payroll File 2023.PNG
    Payroll File 2023.PNG
    35.2 KB · Views: 23
  • Construction payroll hrst 2023.PNG
    Construction payroll hrst 2023.PNG
    93.9 KB · Views: 23

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
hi, can you help the forum help you? It takes a lot of time for the forum to recreate your data page. Can you please use the xl2bb add (link below) and post a mini worksheet of your data (sanitize it for anonymity please).
 
Upvote 1
@LucieLiskova I second the above.
However, maybe the below reflects what you are wanting?

Book1.xlsx
ABCDE
1
2
3
4Period Number
5Week 19
6
7Employee IdTotal HoursHourly RateWagesSalary
8139.5
9299
10323
1140
1250
Sheet3
Cell Formulas
RangeFormula
B8:B12B8=IFERROR(INDEX('Construction Payroll Hrs 2023'!J$9:DR$20,MATCH($A8,'Construction Payroll Hrs 2023'!$A$9:$A$20,0),MATCH($A$5,('Construction Payroll Hrs 2023'!J$5:DR$5),0)),"")


Book1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAYAZBABBBCBDBEBFBGBHBIBJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACBCCCDCECFCGCHCICJCKCLCMCNCOCP
1
2
3
4
5Week 18Week 19Week 20
6
7
8Emp IDTotalTotalTotal
915439.540
102469926
113372340
124
135
Construction Payroll Hrs 2023
 
Upvote 1
Apologies, see below.

Data from Construction Payroll Hrs 2023 - Copy.xlsx will feed into Payroll File 2023.xlsx. Specifically, Construction Payroll Hrs 2023 - Copy.xlsx the 'TOTAL' column number will change in Payroll File 2023.xlsx based on the dropdown in cell A5 and also needs to check for the employee ID (back in Construction Payroll Hrs 2023 - Copy.xlsx).

So if I select week 18 in Payroll Hrs 2023, it should give me 54.00 for Employee ID 1 'Total Hours' (B7). When selecting week 19, I should see 39.5 in Employee ID 1 'Total Hours'.

@Snakehips thank you for the reply, it didn't work though. I hope the minisheet helps?

Construction Payroll Hrs 2023 - Copy.xlsx
CDELMNOPQRSTUVWXAMANAOAPAQARASATAUAVAWAXAYAZBO
3PERIOD 10
4
5Week 18Week 19
6MonTueWedThuFriSatSunWEEK 18MonTueWedThuFriSatSunWEEK 19
701/05/202302/05/202303/05/202304/05/202305/05/202306/05/2023#######08/05/202309/05/202310/05/202311/05/202312/05/202313/05/2023#######
8Employee IDFirst NameSurnameShiftO/TShiftO/TShiftO/TShiftO/TShiftO/TFirst 4 hrsO/TO/TTOTALShiftO/TShiftO/TShiftO/TShiftO/TShiftO/TFirst 4 hrsO/TO/TTOTAL
91BH2SL181817.5152354.0088887.539.5
102BH8887.539.5088887.539.5
113BH8887.539.5088887.539.5
124BH8887.539.5088887.539.5
135BH8887.539.5088887.539.5
146BH8887.539.5088887.539.5
157BH8887.539.5088887.539.5
168BH8887.539.5088887.539.5
179BH8887.539.5088887.539.5
1810BH8887.539.5088887.539.5
1911BH8887.539.5088887.539.5
2012BH8887.539.5088887.539.5
2113BH8887.539.5088887.539.5
2214BH8887.539.5088887.539.5
2315BH8887.539.5088887.539.5
2416BH8887.539.5088887.539.5
2517BH8887.539.5088887.539.5
2618BH8887.539.5088887.539.5
2719BH8887.539.5088887.539.5
2820BH8887.539.5088887.539.5
Construction - Payroll Hrs 2023
Cell Formulas
RangeFormula
AM9:AM28,BO9:BO28AM9=IF(AH9>=39.5,AH9+AI9+AK9+AC9,(AH9+AC9+AI9+AK9))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AT9:AT28Cell Valuecontains "BH"textNO
AT9:AT28Cell Valuecontains "PL"textNO
AT9:AT28Cell Valuecontains "SL"textNO
AT9:AT28Cell Valuecontains "AL"textNO
AR9:AR28Cell Valuecontains "BH"textNO
AR9:AR28Cell Valuecontains "PL"textNO
AR9:AR28Cell Valuecontains "SL"textNO
AR9:AR28Cell Valuecontains "AL"textNO
AV9:AV28Cell Valuecontains "BH"textNO
AV9:AV28Cell Valuecontains "PL"textNO
AV9:AV28Cell Valuecontains "SL"textNO
AV9:AV28Cell Valuecontains "AL"textNO
AP9:AP28Cell Valuecontains "BH"textNO
AP9:AP28Cell Valuecontains "PL"textNO
AP9:AP28Cell Valuecontains "SL"textNO
AP9:AP28Cell Valuecontains "AL"textNO
R9:R28Cell Valuecontains "BH"textNO
R9:R28Cell Valuecontains "PL"textNO
R9:R28Cell Valuecontains "SL"textNO
R9:R28Cell Valuecontains "AL"textNO
P9:P28Cell Valuecontains "BH"textNO
P9:P28Cell Valuecontains "PL"textNO
P9:P28Cell Valuecontains "SL"textNO
P9:P28Cell Valuecontains "AL"textNO
AZ9:AZ28Cell Valuecontains "BH"textNO
AZ9:AZ28Cell Valuecontains "PL"textNO
AZ9:AZ28Cell Valuecontains "SL"textNO
AZ9:AZ28Cell Valuecontains "AL"textNO
AX9:AY28Cell Valuecontains "BH"textNO
AX9:AY28Cell Valuecontains "PL"textNO
AX9:AY28Cell Valuecontains "SL"textNO
AX9:AY28Cell Valuecontains "AL"textNO
AN9:AN28Cell Valuecontains "BH"textNO
AN9:AN28Cell Valuecontains "PL"textNO
AN9:AN28Cell Valuecontains "SL"textNO
AN9:AN28Cell Valuecontains "AL"textNO
V9:X28Cell Valuecontains "BH"textNO
V9:X28Cell Valuecontains "PL"textNO
V9:X28Cell Valuecontains "SL"textNO
V9:X28Cell Valuecontains "AL"textNO
T9:T28Cell Valuecontains "BH"textNO
T9:T28Cell Valuecontains "PL"textNO
T9:T28Cell Valuecontains "SL"textNO
T9:T28Cell Valuecontains "AL"textNO
N9:N28Cell Valuecontains "BH"textNO
N9:N28Cell Valuecontains "PL"textNO
N9:N28Cell Valuecontains "SL"textNO
N9:N28Cell Valuecontains "AL"textNO
L9:L28Cell Valuecontains "BH"textNO
L9:L28Cell Valuecontains "PL"textNO
L9:L28Cell Valuecontains "SL"textNO
L9:L28Cell Valuecontains "AL"textNO



Payroll File 2023..xlsx
ABCDEFGHIJK
1
2
3
4Period Number Week 18
5Week 18Week 19
6Week 20
7Employee IDTotal HoursHourly RateWagesSalaryWeek 21
81 Week 22
92 
103 
114 
125 
136 
147 
158 
169 
1710 
1811 
1912 
2013 
2114 
2215 
2316 
2417 
2518 
2619 
Payroll File 2023
Cell Formulas
RangeFormula
B8B8=IFERROR(INDEX('C:\Users\lucie.liskova\Desktop\[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!AM$9:DR$20,MATCH($A8,'C:\Users\lucie.liskova\Desktop\[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!$A$9:$A$20,0),MATCH($A$5,('C:\Users\lucie.liskova\Desktop\[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!AM$5:DR$5),0)),"")
B9:B26B9=IFERROR(INDEX('C:\Users\lucie.liskova\Desktop\[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!J$9:DR$20,MATCH($A9,'C:\Users\lucie.liskova\Desktop\[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!$A$9:$A$20,0),MATCH($A$5,('C:\Users\lucie.liskova\Desktop\[Construction Payroll Hrs 2023 - Copy.xlsx]Construction - Payroll Hrs 2023'!J$5:DR$5),0)),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
Cells with Data Validation
CellAllowCriteria
A5List=$K$4:$K$8
 
Upvote 0
Your XL2BB does not have your data in the same position as your initial picture.

Based on the XL2BB and without creating a second workbook would something like this work for you ?
Excel Formula:
=INDEX('Construction - Payroll Hrs 2023'!$C$6:$BO$28,
             MATCH($A8,'Construction - Payroll Hrs 2023'!$C$6:$C$28,0),
             MATCH($A$5,'Construction - Payroll Hrs 2023'!$C$6:$BO$6,0))

I have the formula in B8.
And assuming you need to adjust the ranges, the 3 ranges all pivot off the same cell (C6) being the cell that is 2 above Employee ID (same row as the Week 18 which is 2 cells above Total)

If is works just add the IFERROR around it.
 
Upvote 1
Solution
Your XL2BB does not have your data in the same position as your initial picture.

Based on the XL2BB and without creating a second workbook would something like this work for you ?
Excel Formula:
=INDEX('Construction - Payroll Hrs 2023'!$C$6:$BO$28,
             MATCH($A8,'Construction - Payroll Hrs 2023'!$C$6:$C$28,0),
             MATCH($A$5,'Construction - Payroll Hrs 2023'!$C$6:$BO$6,0))

I have the formula in B8.
And assuming you need to adjust the ranges, the 3 ranges all pivot off the same cell (C6) being the cell that is 2 above Employee ID (same row as the Week 18 which is 2 cells above Total)

If is works just add the IFERROR around it.
This is brilliant, Alex. Works just perfect. Thanks so much.
 
Upvote 0
Your XL2BB does not have your data in the same position as your initial picture.

Based on the XL2BB and without creating a second workbook would something like this work for you ?
Excel Formula:
=INDEX('Construction - Payroll Hrs 2023'!$C$6:$BO$28,
             MATCH($A8,'Construction - Payroll Hrs 2023'!$C$6:$C$28,0),
             MATCH($A$5,'Construction - Payroll Hrs 2023'!$C$6:$BO$6,0))

I have the formula in B8.
And assuming you need to adjust the ranges, the 3 ranges all pivot off the same cell (C6) being the cell that is 2 above Employee ID (same row as the Week 18 which is 2 cells above Total)

If is works just add the IFERROR around it.
Hi Alex,

I was trying to apply the same for the rest of the columns in payroll file 2023 - so behind the 'TOTAL' I have few other columns hidden. Behind the employee total hrs I basically want to have a breakdown of overtime, hols, etc. I couldn't make it work and only after a few tries I realized that you based it on the fact that week number is included above the total hours. Is there any other way to make this work for the rest of the columns, you think?

I tried index / match, combination of vlookup / hlookup but nothing works.

I actually posted another thread for it. INDEX / MATCH Used Horizontally & Looking for a Value Based on a Dropdown List

I'd be happy for any help. Thank you very much.


L.
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,275
Members
449,093
Latest member
Vincent Khandagale

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