Using IF and VLOOKUP

camilleso

New Member
Joined
Aug 14, 2019
Messages
15
Can I have one formula with 2 vlookup search criterias? I have one list of IDs, list one contains CUST, second list does not. If IDs contain CUST, i want the vlookup to search one row of data to match and return values. If no CUST exists, i want the vlookup to search a different row of data to match and return values. Do I have to have 2 separate vlookups or can i combine them somehow?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Could you post some sample data and what you expect as a result(s)?
 
Upvote 0
Something similar to this.


Excel 2013/2016
ABCDEF
1Cust IDLookUpCust IDData1Data1
2Test1ATest1A
3Test2BTest2B
4Test3DTest3D
5Test4DTest4D
6Test5ETest5E
Sheet1
Cell Formulas
RangeFormula
B2=IF(VLOOKUP(A2,$D$2:$F$6,2,0)="",VLOOKUP(A2,$D$2:$F$6,3),VLOOKUP(A2,$D$2:$F$6,2,0))
 
Upvote 0
Sure! My expected result is to add the company type to sheet one which contain a list of ids with and without CUST at the beginning of the numeric value. sheet 2 contain the IDs in separate columns (one with numeric IDs and one that start with CUST); both of which have the company types. Can one formula be made to add company type on sheet one based on the ID match on sheet 2?

Columns on sheet 1
Company Type Account ID
12345
45678
91011
CUST-12345
CUST-45678
CUST-91011

Columns on sheet 2
Customer ID Customer ID (Deprecated) Company Type
12345 Network
45678 Agency
91011 Platform
CUST-12345 Publisher
CUST-45678 SSP
CUST-91011 Network
 
Upvote 0
How's this?

Code:
=VLOOKUP(A2,Sheet2!$A$2:$B$7,2,FALSE)

filled down in the B column on Sheet1

Sheet1

12345Network
45678Agency
91011Platform
CUST-12345Publisher
CUST-45678SSP
CUST-91011Network

<colgroup><col style="mso-width-source:userset;mso-width-alt:3803;width:78pt" width="104"> <col style="width:48pt" width="64"> </colgroup><tbody>
</tbody>

Sheet2

12345Network
45678Agency
91011Platform
CUST-12345Publisher
CUST-45678SSP
CUST-91011Network

<colgroup><col style="mso-width-source:userset;mso-width-alt:5083;width:104pt" width="139"> <col style="mso-width-source:userset;mso-width-alt:3218;width:66pt" width="88"> </colgroup><tbody>
</tbody>
 
Last edited:
Upvote 0
Something similar to this.

Excel 2013/2016
ABCDEF
1Cust IDLookUpCust IDData1Data1
2Test1ATest1A
3Test2BTest2B
4Test3DTest3D
5Test4DTest4D
6Test5ETest5E

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=IF(VLOOKUP(A2,$D$2:$F$6,2,0)="",VLOOKUP(A2,$D$2:$F$6,3),VLOOKUP(A2,$D$2:$F$6,2,0))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
Sort of. Column A and D have different labels to represent the Cust IDs on sheet 2, although they both have lookup values I need. Sheet one has a combined list of Cust IDs from Column A and D (so A may have Test1 and D may have 1, although it represents the same Cust ID). If the value isn't found in column A, I will need to search D to return the Cust ID.
 
Upvote 0
One edit, to this:
Sort of. Column A and D have different labels to represent the Cust IDs on sheet 2, although they both have lookup values I need. Sheet one has a combined list of Cust IDs from Column A and D (so A may have Test1 and D may have 1, although it represents the same Cust ID). If the value isn't found in column A, I will need to search D to return the Client Type. Client Type is the lookup value I need returned for each Cust ID if it's labeled Test 1 or 1.
 
Upvote 0
Something like this.


Excel 2013/2016
ABCDEFG
1Cust ID-1C-TypeCust ID-2C-TypeCust IDLookup
212345NetworkCUST-12345Network12345Network
345678AgencyCUST-45678Agency45678Agency
491011PlatformCUST-91011Platform91011Platform
5PublisherPublisherCUST-12345Network
6SSPSSPCUST-45678Agency
7NetworkNetworkCUST-91011Platform
Sheet1
Cell Formulas
RangeFormula
G2=IFERROR(VLOOKUP(F2,$A$2:$B$7,2,0),VLOOKUP(F2,$C$2:$D$7,2,0))
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,012
Members
449,060
Latest member
LinusJE

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