Strange Vlookup Behavior with COLUMNS Function

sayme

New Member
Joined
Apr 21, 2018
Messages
17
Hi guys,

Got a question about vlookup with columns functions. I use, VLOOKUP($B16,$B$4:$D$13,COLUMNS($B:B)+1,0) and I paste the formula across cells C16 and D16 to return matches of author and price. But when I use B$16 instead of $B16 in the formula, it returns a match in author but not price. If it returns a match in author why cant it return a match in price??



ABCD

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]3[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=16365C]#16365C[/URL] , align: center"]Number[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=16365C]#16365C[/URL] "]Book Title[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=16365C]#16365C[/URL] "]Author[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=16365C]#16365C[/URL] "]Price[/TD]

[TD="align: center"]4[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]1[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]A Game of Thrones[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]George R.R.[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$19.77[/TD]

[TD="align: center"]5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]2[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Go to Sleep[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Adam Mansbach[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$8.22[/TD]

[TD="align: center"]6[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]3[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]A Dance with Dragons[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]George R.R.[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$18.81[/TD]

[TD="align: center"]7[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]4[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]The Hunger Games[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Suzanne Collins[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$4.94[/TD]

[TD="align: center"]8[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]The Original Argument[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Glenn Beck[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$7.99[/TD]

[TD="align: center"]9[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]6[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Heaven is for Real[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Todd Burpo[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$9.34[/TD]

[TD="align: center"]10[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]7[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Unbroken[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Laura Hillenbrand[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$13.99[/TD]

[TD="align: center"]11[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]8[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Smokin' Seventeen[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Janet Evanovich[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$15.21[/TD]

[TD="align: center"]12[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]9[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]In the Garden of Beasts[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Erik Larson[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$13.78[/TD]

[TD="align: center"]13[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: center"]10[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Catching Fire[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] "]Suzanne Collins[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=538DD5]#538DD5[/URL] , align: right"]$8.97[/TD]

</tbody>
Sheet2
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
But when I use B$16 instead of $B16 in the formula, it returns a match in author but not price. If it returns a match in author why cant it return a match in price??
Because when you make that change and then copy the formula from column C to column D it becomes

=VLOOKUP(C$16,$B$4:$D$13,COLUMNS($B:C)+1,0)

This formula is trying to look up what is in column C (the author - returned from the formula in C16) in column B, which contains book titles, not authors.
 
Upvote 0
That is because the $ sign is an absolute reference. Meaning no matter where you put your formula it will always reference to a pecific column or a row. So, $B absolute column and $16 absolute row. So when you use B$16 and drag formula/or copy formula the result for author is correct, but for an amount reference changed to C$16. You want to keep $B16 to keep absolute reference on your column B since it will not change in this case and keep row (16) as is.
 
Upvote 0
Hi,

If you Want to use your VLOOKUP in the manner you described:

Instead of =VLOOKUP($B16,$B$4:$D$13,COLUMNS($B:B)+1,0)

Changed to =VLOOKUP(B$16,$B$4:$D$13,COLUMNS($B:B)+1,0)

Then you would Also need to change $B$4:$D$13 to B$4:$D$13 and COLUMNS($B:B) to COLUMNS($B:$B)

So now the formula will look like =VLOOKUP(B$16,B$4:$D$13,COLUMNS($B:$B)+1,0)

But since COLUMNS($B:$B) is basically a constant of 1, you would No longer need that function,

So the formula can just be =VLOOKUP(B$16,B$4:$D$13,2,0)

Now you can drag Either modified version of your VLOOKUP formula from Column C to Column D and get correct results for Arthur and Price.

See below for comparison, All C Column formulas copied to D:


Book1
ABCD
3NumberBook TitleAuthorPrice
41A Game of ThronesGeorge R.R.$19.77
52Go to SleepAdam Mansbach$8.22
63A Dance with DragonsGeorge R.R.$18.81
74The Hunger GamesSuzanne Collins$4.94
85The Original ArgumentGlenn Beck$7.99
96Heaven is for RealTodd Burpo$9.34
107UnbrokenLaura Hillenbrand$13.99
118Smokin' SeventeenJanet Evanovich$15.21
129In the Garden of BeastsErik Larson$13.78
1310Catching FireSuzanne Collins$8.97
14
15
16Go to SleepAdam Mansbach8.22
17Adam Mansbach8.22
18Adam Mansbach8.22
Sheet142
Cell Formulas
RangeFormula
C16=VLOOKUP($B16,$B$4:$D$13,COLUMNS($B:B)+1,0)
C17=VLOOKUP(B$16,B$4:$D$13,COLUMNS($B:$B)+1,0)
C18=VLOOKUP(B$16,B$4:$D$13,2,0)
 
Last edited:
Upvote 0
Now you can drag Either modified version of your VLOOKUP formula from Column C to Column D and get correct results for Arthur and Price.
I disagree. I have used your two modified formulas in rows 17 & 18 as suggested below, but they do not return the correct results when dragged to column D for price.

(Perhaps I'm not understanding, but I'm not sure why the OP is wanting to change a formula that seems to be doing the job perfectly as it is. :huh:)

Excel Workbook
BCD
3Book TitleAuthorPrice
4A Game of ThronesGeorge R.R.$19.77
5Go to SleepAdam Mansbach$8.22
6A Dance with DragonsGeorge R.R.$18.81
7The Hunger GamesSuzanne Collins$4.94
8The Original ArgumentGlenn Beck$7.99
9Heaven is for RealTodd Burpo$9.34
10UnbrokenLaura Hillenbrand$13.99
11Smokin' SeventeenJanet Evanovich$15.21
12In the Garden of BeastsErik Larson$13.78
13Catching FireSuzanne Collins$8.97
14
15
16Catching FireSuzanne Collins8.97
17Suzanne Collins4.94
18Suzanne Collins4.94
Formula
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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