VLOOKUP Fails

PaulAsaran

New Member
Joined
Feb 11, 2019
Messages
22
I've built a timesheet with 15-minute increments. Users enter their task and what project the task is part of, and a single project can have multiple tasks. All projects are in one column and all tasks are in a neighboring column. Total time is listed beside them. The range is D2:G166 (NOTE: Column F is a notes column and has no value for the purposes of the summary table). The sheet is named "Detail". See example below:

[TABLE="class: grid, width: 300, align: center"]
<tbody>[TR]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]G[/TD]
[/TR]
[TR]
[TD]Task
[/TD]
[TD]Project
[/TD]
[TD]Hours
[/TD]
[/TR]
[TR]
[TD]Task 1[/TD]
[TD]Project 1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Task 1[/TD]
[TD]Project 1[/TD]
[TD].5[/TD]
[/TR]
[TR]
[TD]Task 2[/TD]
[TD]Project 2[/TD]
[TD].25[/TD]
[/TR]
[TR]
[TD]Task 3[/TD]
[TD]Project 1[/TD]
[TD].25[/TD]
[/TR]
[TR]
[TD]Task 2[/TD]
[TD]Project 2[/TD]
[TD].25[/TD]
[/TR]
[TR]
[TD]Task 4[/TD]
[TD]Project 3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Task 4[/TD]
[TD]Project 3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Task 4[/TD]
[TD]Project 3[/TD]
[TD].75[/TD]
[/TR]
</tbody>[/TABLE]
I've been using the timesheet for nearly a year now and it works fine, but I've decided it's time to create a summary page for it on a different sheet. My first step was to create a list of unique tasks using an array formula:

Code:
{=IFERROR(INDEX(Detail!$D$2:$D$166,MATCH(0,COUNTIF($A$1:A1,Detail!$D$2:$D$166),0)),"")}
This formula was then drag-copied down over the range A2:A167 and works fine.

Next, I created an Hours column that determines how much time is paid to each individual task, regardless of where it appears in the original table:

Code:
=IF(OR(A2="",A2=0),"",SUMIF(Detail!$D$2:$D$166,A2,Detail!$G$2:$G$166))
The formula uses the result of the previous formula as the criteria for the SUMIF to locate the appropriate numbers to sum up. This too works just fine across the range C2:C167.

Now we get to the problem. In column B, I created a formula that would determine what project each task was assigned to:

Code:
=IFERROR(VLOOKUP(A2,Detail!$D$2:$E$166,2),"")
Like the previous formula for summing hours, this one is referencing the result of the first formula as the VLOOKUP lookup value. But instead of doing that, it targets seemingly random tasks. I can't figure out why it would do that, but I've determined that all values are correct as I understand VLOOKUP—and I should understand it, as I use it frequently. Is it because the first formula is an array formula? If that's a problem, why does the SUMIF formula work fine when the VLOOKUP doesn't? I am thoroughly confused and can't seem to locate any information on this particular problem in my online searches, so here we are.

The final summary table is meant to look like the below (using the example table above as a reference):

[TABLE="class: grid, width: 300, align: center"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[/TR]
[TR]
[TD]Task
[/TD]
[TD]Project
[/TD]
[TD]Hours
[/TD]
[/TR]
[TR]
[TD]Task 1[/TD]
[TD]Project 1[/TD]
[TD].5[/TD]
[/TR]
[TR]
[TD]Task 2[/TD]
[TD]Project 2[/TD]
[TD].5[/TD]
[/TR]
[TR]
[TD]Task 3[/TD]
[TD]Project 1[/TD]
[TD].25[/TD]
[/TR]
[TR]
[TD]Task 4[/TD]
[TD]Project 3[/TD]
[TD].75[/TD]
[/TR]
</tbody>[/TABLE]
 

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.
the extra ,0 forced an exact match

=IFERROR(VLOOKUP(A2,Detail!$D$2:$E$166,2,0),"")
 
Upvote 0
If your list isn't sorted, you need to specify an exact match
=IFERROR(VLOOKUP(A2,Detail!$D$2:$E$166,2,0),"")
 
Upvote 0
Solution
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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