VLookup & Index or Match

kizzie37

Well-known Member
Joined
Oct 23, 2007
Messages
575
Office Version
  1. 365
I have a sheet (Worker) with Emp Id (Column A) then the employee's manager name (Column M), then I have a reference sheet (sheet 1 ) with a table of Manager names and Department Names (Column P - Manager Name & column Q - Department Name).

What I want is a formula to go into another sheet (Misc Info Column E) to first look up the emp ID in the "Worker" sheet and find out the manager name, then look up the manager name in "sheet 1" table and return the department name.

I am not sure how to compile the formula. Can anyone help?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
where do you want the dept name added to - you mention a few sheets
I have a sheet (Worker) with Emp Id (Column A) then the employee's manager name (Column M),
as you already have the managers name here - you could just lookup the dept

Not sure why you are looking up the employee ID when its in the sheet worker

maybe i'm missing understanding what you want
Worker : = EMP ID , MANAGERS NAME
SHEET1 :- Manager Name, Dept
Misc Info: whats in here - column E is where you want the Dept returned - what info is in here ? -- is it just the Employee name

Anyway - I suspect a index/match will be what you are after - probably nested

Note: Images are difficult to see , and also requires that I input all the data myself, which is very time consuming.

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC , then put the sample spreadsheet onto a share
I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed
 
Last edited:
Upvote 0
where do you want the dept name added to - you mention a few sheets

as you already have the managers name here - you could just lookup the dept

Not sure why you are looking up the employee ID when its in the sheet worker

maybe i'm missing understanding what you want
Worker : = EMP ID , MANAGERS NAME
SHEET1 :- Manager Name, Dept
Misc Info: whats in here - column E is where you want the Dept returned - what info is in here ? -- is it just the Employee name

Anyway - I suspect a index/match will be what you are after - probably nested

Note: Images are difficult to see , and also requires that I input all the data myself, which is very time consuming.

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC , then put the sample spreadsheet onto a share
I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

I am restricted from using the XL2BB and I cant trust the file share, the best I can do is below:
 

Attachments

  • Screenshot 2022-10-27 093937.png
    Screenshot 2022-10-27 093937.png
    14.2 KB · Views: 6
Upvote 0
=INDEX($F$2:$F$4,MATCH(INDEX($B$2:$B$11,MATCH(I2,$A$2:$A$11,0)),$E$2:$E$4,0))

I have put in the same sort of format

so you just need to change the range and add the sheet names

I'll look at that later and maybe put on dropbox

=INDEX($F$2:$F$4,MATCH(INDEX($B$2:$B$11,MATCH(I2,$A$2:$A$11,0)),$E$2:$E$4,0))

here is the XL2BB version
Book1
ABCDEFGHIJ
1empIDmanager nameManager NameSegmentEmpIdSegment
2123456-00joe bloggsjoe bloggsMI5123456-00MI5
3123456-01joe bloggsBob SmithUB40123456-01MI5
4123456-02joe bloggsHarry HTreasury123456-02MI5
5123456-03Bob Smith123456-03UB40
6123456-04Bob Smith123456-04UB40
7123456-05Bob Smith123456-05UB40
8123456-06Bob Smith123456-06UB40
9123456-07Harry H123456-07Treasury
10123456-08Harry H123456-08Treasury
11123456-09Harry H123456-09Treasury
12#N/A
13#N/A
14#N/A
15
16
17WORKERSheet 1Misc Info
Sheet1
Cell Formulas
RangeFormula
J2:J14J2=INDEX($F$2:$F$4,MATCH(INDEX($B$2:$B$11,MATCH(I2,$A$2:$A$11,0)),$E$2:$E$4,0))
 
Upvote 0
i have made the different sheets and used
=INDEX('Sheet 1'!$B$2:$B$4,MATCH(INDEX(Worker!$B$2:$B$11,MATCH(A2,Worker!$A$2:$A$11,0)),'Sheet 1'!$A$2:$A$4,0))

you can add a IFERROR - to stop the error message if cannot be found

=IFERROR(INDEX('Sheet 1'!$B$2:$B$4,MATCH(INDEX(Worker!$B$2:$B$11,MATCH(A2,Worker!$A$2:$A$11,0)),'Sheet 1'!$A$2:$A$4,0)),"")

If the names are not exact - it will not match

change range to match your data ranges

Usually excel uses sheet1 - no space - but you have a space Sheet 1 - so i used that

dropbox - will only be on the share for a few days


XL2BB versions of each sheet

nested Index - ETAF.xlsx
AB
1EmpIdSegment
2123456-00MI5
3123456-01MI5
4123456-02MI5
5123456-03UB40
6123456-04UB40
7123456-05UB40
8123456-06UB40
9123456-07Treasury
10123456-08Treasury
11123456-09Treasury
12#N/A
13#N/A
14#N/A
Misc Info
Cell Formulas
RangeFormula
B2:B14B2=INDEX('Sheet 1'!$B$2:$B$4,MATCH(INDEX(Worker!$B$2:$B$11,MATCH(A2,Worker!$A$2:$A$11,0)),'Sheet 1'!$A$2:$A$4,0))


nested Index - ETAF.xlsx
AB
1Manager NameSegment
2joe bloggsMI5
3Bob SmithUB40
4Harry HTreasury
Sheet 1



nested Index - ETAF.xlsx
AB
1empIDmanager name
2123456-00joe bloggs
3123456-01joe bloggs
4123456-02joe bloggs
5123456-03Bob Smith
6123456-04Bob Smith
7123456-05Bob Smith
8123456-06Bob Smith
9123456-07Harry H
10123456-08Harry H
11123456-09Harry H
Worker
 
Upvote 0
Since you have Excel 365, you can take advantage of the new XLOOKUP, which rolls INDEX, MATCH and IFERROR into one formula. You may also benefit from arranging your data in named tables to avoid having to manually update data ranges.

Book3
ABCDEFGHIJ
1empIDmanager nameManager NameSegmentEmpIdSegment
2123456-00joe bloggsjoe bloggsMI5123456-00MI5
3123456-01joe bloggsBob SmithUB40123456-01MI5
4123456-02joe bloggsHarry HTreasury123456-02MI5
5123456-03Bob Smith123456-03UB40
6123456-04Bob Smith123456-04UB40
7123456-05Bob Smith123456-05UB40
8123456-06Bob Smith123456-06UB40
9123456-07Harry H123456-07Treasury
10123456-08Harry H123456-08Treasury
11123456-09Harry H123456-09Treasury
Sheet4
Cell Formulas
RangeFormula
J2:J11J2=XLOOKUP(XLOOKUP([@EmpId],Table1[empID],Table1[manager name]),Table2[Manager Name],Table2[Segment])
 
Upvote 0

Forum statistics

Threads
1,215,443
Messages
6,124,890
Members
449,194
Latest member
JayEggleton

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