Combine IF with Vlookup

akswartz85

New Member
Joined
Mar 31, 2010
Messages
49
I have one table with unique identifiers and different years. I want to pull amounts from additional tabs into the cells only labeled with the $ below:

Tab name: MERGED
Unique ID201520162017
1234A$$$
4567B$$$
9038B$$$
9038J$$$

<tbody>
</tbody>

Additional tabs (each ID may be listed 1+ times):
Tab name: ALL AMOUNTS
Unique IDYEARAmount
1234A2015342
1234A2016394
4567B2017390
4567B2015908
9038J2017908
9038J20163221
9038B20179033

<tbody>
</tbody>

I'd like to pull the amount into the proper year column by ID. Ideally, it would look like:

Unique ID201520162017
1234A$342$394No amount
4567B$908No amount$390
9038BNo amountNo amount$9033
9038JNo amount$3221$908

<tbody>
</tbody>

I was thinking I could write an IF(Vlookup)
=if('all amounts'$b2="2015",vlookup('merged'$a2,'all amounts'$a:$c,3,false),"No amount")

(forgive me if I forgot any formatting, I'm making this dataset up bc my actual data has identifying info)

But when I drag the formula down, I just get "no amount" (i.e. the if failed).

Thoughts? My head is spinning.
 
Hmm, it appears it has something to do with me changing this: map_fall_math_only!$B:$B="2015"

to "2015" instead of a cell reference. Do you know why?
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Another solution you can try

Just enter,

=IFERROR(VLOOKUP(A2&2015,IF({1,0},INDEX(map_fall_math_only!A1:A2000&map_fall_math_only!B1:B2000,0),map_fall_math_only!O1:O2000),2,0),"No test result")

you can extend or shorten the reference highlighted in red as per your requirement.
 
Last edited:
Upvote 0
Hmm, it appears it has something to do with me changing this: map_fall_math_only!$B:$B="2015"

to "2015" instead of a cell reference. Do you know why?
it might be in a different format or with a space at the end or beginning of 2015 in your reference cell. re-type it manually and change the format to number and try.
 
Upvote 0
So, I shifted your formula ot my actual data set, and it's not working.

I have:
=IFNA(INDEX(map_fall_math_only!$O:$O,MATCH($A2,IF(map_fall_math_only!$B:$B="2015",map_fall_math_only!$A:$A),0)),"No test result")

Where map_fall_math_only = all amounts
map_fall_math_only!O:O = the col I'm trying to pull into merged
"" $b:$b = year that I want to filter on
"" $a:$a = unique identifier across both sheets

I am just getting "no test result" on everything. I am clicking ctl+ shift + enter.

Thoughts?

Try to unquote 2015...

{=IFNA(INDEX(map_fall_math_only!$O:$O,MATCH($A2,IF(map_fall_math_only!$B:$B=2015,map_fall_math_only!$A:$A),0)),"No test result")}
 
Upvote 0

Forum statistics

Threads
1,214,660
Messages
6,120,787
Members
448,994
Latest member
rohitsomani

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