Easier formula for nestled if statement

Paigan

New Member
Joined
Jun 10, 2014
Messages
12
Hello everybody,

I am trying to find an easier way to look up values out of Database sheet if certain criteria are met.
Code:
{=IF(A2=1;INDEX('Source Sheet'!$B$2:$B$18;(MATCH(2;'Source Sheet'!$A$2:$A$18;0)));IF(A2=2;(INDEX('Source Sheet'!$C$2:$C$18;MATCH(3;'Source Sheet'!$A$2:$A$18;0)));IF(A2=3;(INDEX('Source Sheet'!$D$2:$D$18;MATCH(4;'Source Sheet'!$A$2:$A$18;0)));IF(A2=4;(INDEX('Source Sheet'!$E$2:$E$18;MATCH(4;'Source Sheet'!$A$2:$A$18;0)));IF(A2=5;(INDEX('Source Sheet'!$F$2:$F$18;MATCH(4;'Source Sheet'!$A$2:$A$18;0)));0)))))}

My boss is convinced there is a formula built in to excel. Before I tell him a defenite "No" I want to make really sure there is no simpler way.

I am aware I could define a custom function within VBA to do different lookups for different criteria (e.g. if there are more than 7) to make it look simpler and if need be I would create one.

For reference, my workbook simplified looks something like this:
Destinationsheet:
CriteriaLookup for Criteria
1nestled if statement
2nestled if statement
3nestled if statement
4nestled if statement
5nestled if statement

<tbody>
</tbody>
Sourcesheet:
uuuvvvwwwxxxyyyzzzaaa
1abcdeabc
2abcdebcd
3abcdecde
4abcdeabc
5abctraebcd
6abcdecde
7abcdeabc
8abcdebcd
9abcdecde
5abcdeabc
11abcdebcd
12abcdecde
13abasdfdeabc
1abcdebcd

<tbody>
</tbody>

Does anyone know of a way to do this in an easier way and for more than 7 criteria without using VBA?

Best

Paigan
 
Hi,

How about creating a table for the column to return for each Criteria e.g. in Y1:Z7

Criteria Column
1 1
2 2
3 3
4 4
abc 12
xyz 27

then you can nest Vlookups as below

Code:
=VLOOKUP($A2,'Source Sheet'!$A$2:$F$18,VLOOKUP($A2,$Y$1:$Z$7,2,0),0)

again, untested.

Eric.
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hey Eric,

thanks for the workaround.
Yes that one work very well! The only "problem" is the helper table. It is supposed to do everything in one cell.
I will try and write a custom formula to do what I need. Will post my final solution here.
Maybe It will help somebody else solve a similar problem :).

Regards and thanks everybody for the help and time!

Paigan
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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