VLOOKUP 2 values

Nanaia

Active Member
Joined
Jan 11, 2018
Messages
306
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Is it possible to use VLOOKUP and have it search for 2 values to find a result?
To explain, I want to be able to have the VLOOKUP formula in G3 look at A3 & B3 and find result in the array on another sheet. And this description sounds muddled to my coffee deprived brain so I'm going to attempt to add to it without making it more confusing.

The following is my array on a secondary worksheet tab. On the primary worksheet I have it set up so we enter the drawing number and the face size and am using VLOOKUP to give me the online code listed in column C here. I realized after the fact that I need it to use BOTH the drawing number AND the face size in order to get the right code. I want it to kick out the message "NEEDS PROGRAM" if there isn't a code. Is there a way to combine that in VLOOKUP?
[TABLE="width: 496"]
<tbody>[TR]
[TD]DRW#
[/TD]
[TD]FACE
[/TD]
[TD]Online Code
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]16
[/TD]
[TD]"ABCD\DWG_1.DOC//FaceX 108 FaceZ 16"
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]24
[/TD]
[TD]"ABCD\DWG_1.DOC//FaceX 108 FaceZ 24"
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]8
[/TD]
[TD]"ABCD\DWG_2.DOC//FaceX 108 FaceZ 8"
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]12
[/TD]
[TD]"ABCD\DWG_2.DOC//FaceX 108 FaceZ 12"
[/TD]
[/TR]
[TR]
[TD]18
[/TD]
[TD]20
[/TD]
[TD]"ABCD\DWG_18.DOC//FaceX 108 FaceZ 20"
[/TD]
[/TR]
[TR]
[TD]18
[/TD]
[TD]16
[/TD]
[TD]"ABCD\DWG_18.DOC//FaceX 108 FaceZ 16"
[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
is this what you want?

Excel 2010[TABLE="class: grid, width: 400"]
<colgroup><col><col><col><col><col><col><col><col></colgroup><tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD]"ABCD\DWG_1.DOC//FaceX 108 FaceZ 24"[/TD]
[/TR]
</tbody>[/TABLE]
Sheet3

[TABLE="class: grid, width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="class: grid, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR="class: grid"]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G3[/TH]
[TD="align: left"]{=IFERROR(INDEX(Sheet4!C2:C7,MATCH(Sheet3!A3&Sheet3!B3,Sheet4!A2:A7&Sheet4!B2:B7,0)),"Needs Program")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]



Excel 2010[TABLE="class: grid, width: 500"]
<colgroup><col><col><col><col></colgroup><tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD]DRW#[/TD]
[TD]FACE[/TD]
[TD]Online Code[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]16[/TD]
[TD]"ABCD\DWG_1.DOC//FaceX 108 FaceZ 16"[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]24[/TD]
[TD]"ABCD\DWG_1.DOC//FaceX 108 FaceZ 24"[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]8[/TD]
[TD]"ABCD\DWG_2.DOC//FaceX 108 FaceZ 8"[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]12[/TD]
[TD]"ABCD\DWG_2.DOC//FaceX 108 FaceZ 12"[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]20[/TD]
[TD]"ABCD\DWG_18.DOC//FaceX 108 FaceZ 20"[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]16[/TD]
[TD]"ABCD\DWG_18.DOC//FaceX 108 FaceZ 16"[/TD]
[/TR]
</tbody>[/TABLE]
Sheet4
 
Last edited:
Upvote 0
Potentially..... I'm having trouble getting it to work using my sheets though. Sheet names are TEST (the primary sheet that the formula is located on-your sheet 3 I believe), and the array on mine is located on a tab named FOLDED. When I replace your sheet names with mine I get an "N/A" error.
 
Upvote 0
I went through it again and got rid of the "N/A" error. Now it tells me "NEEDS PROGRAM" even if the A & C are there and an associated program is listed in column C. Any ideas what I'm doing wrong?
 
Upvote 0
This is an array formula and needs Control + Shift+ Enter not just enter. If you do not use CSE you will get an error and the iferror will return NEEDS PROGRAM.
 
Upvote 0
I've never used that technique before. I think I got it to work. Thanks!
 
Upvote 0
Do the columns need to be directly next to each other? I'm tweaking this formula to be used in a similar situation and keep getting an #NA error. The INDEX array column (shown here as sheet4 column C) is sheet 2 column I, and the MATCH look up values are located in sheet 1 column B & C, the MATCH array is sheet 2 column B & D. Have I exceeded the abilities of the formula? Or just my own?
 
Upvote 0
The columns do not need to be next to each other


Excel 2010
ABCDEFG
3124"ABCD\DWG_1.DOC//FaceX 108 FaceZ 24"
Sheet3
Cell Formulas
RangeFormula
G3{=IFERROR(INDEX(Sheet4!D2:D7,MATCH(Sheet3!A3&Sheet3!C3,Sheet4!A2:A7&Sheet4!C2:C7,0)),"Needs Program")}
Press CTRL+SHIFT+ENTER to enter array formulas.



Excel 2010
ABCD
1DRW#FACEOnline Code
2116"ABCD\DWG_1.DOC//FaceX 108 FaceZ 16"
3124"ABCD\DWG_1.DOC//FaceX 108 FaceZ 24"
428"ABCD\DWG_2.DOC//FaceX 108 FaceZ 8"
5212"ABCD\DWG_2.DOC//FaceX 108 FaceZ 12"
61820"ABCD\DWG_18.DOC//FaceX 108 FaceZ 20"
71816"ABCD\DWG_18.DOC//FaceX 108 FaceZ 16"
Sheet4



You do need to use the same order. the lookup value is drw# (A3) and then Face (C3). So the lookup array needs to be in the same order column A (Drw#) then column C (Face) .
Code:
MATCH([COLOR=#FF0000]Sheet3!A3&Sheet3!C3[/COLOR],[COLOR=#006400]Sheet4!A2:A7&Sheet4!C2:C7[/COLOR],0)
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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