Vlookup FOLLOWED by IF Statement?

njdevils3027

New Member
Joined
Jun 27, 2019
Messages
3
[FONT=&quot]Hi All,

[/FONT]
[FONT=&quot]I am trying to set up an Excel formula based off of a mapping table. I have a set of "level 1" codes in my data set and can match them to the mapping table that also includes these "level 1" codes via a Vlookup. That takes care of about 75/80% of the data set.

[/FONT]
[FONT=&quot]There are some lines of data that do not include this "level 1" code and I need to map it via a "level 2" code. However, this "level 2" code cannot be brought into the mapping table (for a separate reason).

[/FONT]
[FONT=&quot]My solution was to vlookup based on the "level 1" code and then follow that statement with a series of IF(cell="X","Y) statements to catch all of the "level 2" codes. This formula will be used for many different files in the future so it is best for me to catch all in one formula rather than hard code over any N/A's in this file.

[/FONT]
[FONT=&quot]I have no trouble BEGINNING the formula with the IF statements and ending it with the Vlookup. However, this overrides the Vlookup in the cases where the mapping does not align. I need a way for the Vlookup to be the FIRST function in the formula, with those IF's coming afterwards. Is that possible?

[/FONT]
[FONT=&quot]Something like:[/FONT]
[FONT=&quot]IFERROR(vlookup("level 1" cell,array from mapping table,count in mapping table, false), IF("level 2" cell="X","Y")

[/FONT]
[FONT=&quot]I have not been able to get that to work. Is there a better way around it?[/FONT]
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,371
Welcome to Mr Excel forum

Maybe something like this
=IF(A2="level 1",VLOOKUP(A2,....),otherformula)

Adjust A2 to fit your actual case and replace otherformula with the formula that deals with level 2

Hope this helps

M.
 

njdevils3027

New Member
Joined
Jun 27, 2019
Messages
3
Thank you for the post, Marcelo. The issue is, there are about 310 "level 1" codes form this mapping table that I am using the vlookup for. I need the output for those to match what's in the mapping table. To have an IF statement for all of thos ewould be very cumbersome, right? Am I looking at this the wrong way?
 

njdevils3027

New Member
Joined
Jun 27, 2019
Messages
3
Is it possible to do an IFERROR with many arguments? So IFERROR beginning with the Vlookup, and then IF statements for the level 2 codes?
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,371
Thank you for the post, Marcelo. The issue is, there are about 310 "level 1" codes form this mapping table that I am using the vlookup for. I need the output for those to match what's in the mapping table. To have an IF statement for all of thos ewould be very cumbersome, right? Am I looking at this the wrong way?
I'm not sure what you're trying to do
Could you provide a small data sample along with expected results

M.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,000
Messages
5,465,932
Members
406,453
Latest member
MarkB5432

This Week's Hot Topics

Top