How to use If Statement or Vlookup when comparing lists of names

Dprobasco

New Member
Joined
Oct 15, 2023
Messages
12
Office Version
  1. 365
Platform
  1. MacOS
I have a spreadsheet with three worksheets

The first worksheet contains a list of 5045 names of people in one column and related individual ID numbers in another column

The second spreadsheet has a list of 345 names of people in a column

The third spreadsheet has a list of 200 names of people in a column

For each of the second and third spreadsheets I want to compare that list to the longer list and when it matches, put the related ID number in the next column.

Which is better to use, the If statement or the Vlookup statement.

How would I use the statement to make it work.

I tried the if statement but ended up with the Spill error message

Dale
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
index/match or xlookup

not sure what ranges you are using

assumin the ID is in sheet1 column B

=index(sheet1!B2:B10000,MATCH(A2,sheet1!A2:A10000,0))

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.

This will possibly enable a quicker and more accurate solution for you.

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

Make sure you set any share or google to share to everyone
 
Upvote 0
index/match or xlookup

not sure what ranges you are using

assumin the ID is in sheet1 column B

=index(sheet1!B2:B10000,MATCH(A2,sheet1!A2:A10000,0))

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.

This will possibly enable a quicker and more accurate solution for you.

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

Make sure you set any share or google to share to everyone
Thanks so much for your quick reply.

I will try the upload later today but heading out now to donate blood.
 
Upvote 0
index/match or xlookup

not sure what ranges you are using

assumin the ID is in sheet1 column B

=index(sheet1!B2:B10000,MATCH(A2,sheet1!A2:A10000,0))

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.

This will possibly enable a quicker and more accurate solution for you.

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

Make sure you set any share or google to share to everyone
I have been trying to get the addin loaded but can’t seem to get it to load.

Further explanation on my question

In a sheet called Part I have the following
I have a list of 5045 items with an ID number in column A and in Column B I have the persons name.

In a second sheet called Client I have a list of 377 people with their name in column A

I have a third sheet called Volunteer with a list of 145 people with their name in column A.

I want to have Excel compare the list in sheet Part to the list in the sheet called Client. When it finds a match then tale the ID number from the appropriate cell next to the comparable name and copy it next to the comparable name Excel found in the sheet called Client.

The list in the Part sheet includes people that have been either a Client or Volunteer over the years. Some of the people in this long list may have moved, died, etc. so are no longer active.

The list in the Client worksheet are the Clients that are actively receiving services from us and thus want to get their ID linked to their name.

A similar issue is with the sheet called Volunteer.

Unfortunately, the DB program only provides the longer list with the ID number so I am trying to link the proper name with the proper ID number.

Dale
 
Upvote 0
In a sheet called Part I have the following
I have a list of 5045 items with an ID number in column A and in Column B I have the persons name.
OK, so same sort of formula as i posted
Index( the ID range wanted to return from part , match ( cell with name , the name range in part , 0)

in each sheet - client put

=index( part!$A$2:$A$10000, match( A2 , part!$B$2:$A$10000, 0))

same for sheet volunteer

this will use the match of name in A2 , and look down the column B in part sheet until it finds an exact match of the name and then return the value from column A the ID from part sheet
 
Upvote 0
OK, so same sort of formula as i posted
Index( the ID range wanted to return from part , match ( cell with name , the name range in part , 0)

in each sheet - client put

=index( part!$A$2:$A$10000, match( A2 , part!$B$2:$A$10000, 0))

same for sheet volunteer

this will use the match of name in A2 , and look down the column B in part sheet until it finds an exact match of the name and then return the value from column A the ID from part sheet
Ok once again thanks for the quick response.
It works great. I did note the typo in the last part of the formula part!$B$2:$A$10000,0)). Changed the A to a B.

Again great response, so thankful.
 
Upvote 0
Since you have MS365 you can get all the results with a single formula instead of copying down the hundreds of rows you have. You can still use INDEX/MATCH or XLOOKUP as already suggested with the whole range at once but here is an option with VLOOKUP. You just need to adjust the ranges to suit your data.

Dprobasco.xlsm
AB
1IDName
2ID1Name 1
3ID2Name 2
4ID3Name 3
5ID4Name 4
6ID5Name 5
7ID6Name 6
8ID7Name 7
9ID8Name 8
10ID9Name 9
Part


Dprobasco.xlsm
AB
1ClientID
2Name 3ID3
3Name 8ID8
4Name12Not found
5Name 1ID1
6
Client
Cell Formulas
RangeFormula
B2:B5B2=IFNA(VLOOKUP(A2:A5,CHOOSECOLS(Part!A2:B10000,2,1),2,0),"Not found")
Dynamic array formulas.


Dprobasco.xlsm
AB
1VolunteerID
2Name 5ID5
3Name 55Not found
4Name 2ID2
5Name 7ID7
6Name 6ID6
7
Volunteer
Cell Formulas
RangeFormula
B2:B6B2=IFNA(VLOOKUP(A2:A6,CHOOSECOLS(Part!A2:B10000,2,1),2,0),"Not found")
Dynamic array formulas.
 
Upvote 0
Ok another question, I now have worksheets of Part, Client and Volunteer.

Using the list of names in the Client sheet, check for matches in the Part sheet and when found insert the word Client next to the match.

I would also do the same for the Volunteer sheet.

I am guessing i use something similar for this but can’t seem to get it to work.

Dale
 
Upvote 0
Ok another question, I now have worksheets of Part, Client and Volunteer.

Using the list of names in the Client sheet, check for matches in the Part sheet and when found insert the word Client next to the match.

I would also do the same for the Volunteer sheet.

I am guessing i use something similar for this but can’t seem to get it to work.

Dale
Just an update on my last request. Using all the info provided I got it figured out so thanks to you all

Dale
 
Upvote 0
Using all the info provided I got it figured out so thanks to you all
Good news, thanks for letting us know. (y)
Not sure how you did it but this is how I might have done it using the same sample Client and Volunteer sheets I used above. Again, all the results at once with a 'spill' formula.

Dprobasco.xlsm
ABC
1IDName
2ID1Name 1Client
3ID2Name 2Volunteer
4ID3Name 3Client
5ID4Name 4Not found
6ID5Name 5Volunteer
7ID6Name 6Volunteer
8ID7Name 7Volunteer
9ID8Name 8Client
10ID9Name 9Not found
Part
Cell Formulas
RangeFormula
C2:C10C2=IF(ISNUMBER(XMATCH(B2:B10,Client!A2:A10000)),"Client",IF(ISNUMBER(XMATCH(B2:B10,Volunteer!A2:A10000)),"Volunteer","Not found"))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
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