# A different HLOOKUP problem #REF!

Folks,
I had to move a table in my worksheet that is used in a HLOOKUP function. The worksheet is attached. I am now getting a different error that I cannot see: #REF!
Please open attachment to see what I mean and help me to understand what is wrong.
Thanks
HLookup-problem.xlsm
###### Who is Participating?

Commented:
The difference is in the structure.
NB_VC: In the results you were counting the rows of the result set.  Wish I had thought of that as it eliminated my additional row column.  I think because the rows of the result set were used to determine the rows of the source data it is harder for the user to know where to place/troubleshoot the formula.
ssaqibh: The results were based on the row count difference between the result row and the source data, which is not intuitive, although the formula did not change.  (But the user would have had to know to adjust the row number difference constant.
lvbarnes: I set the row number in the results and then found that row number based on the start of the source data so that the results and source are not directly linked.  From a movement standpoint its cleaner and is less work for the user and will convert better to table design.  However, the formula could be cleaned up more to handle additional exceptions.
0

EngineerCommented:
=IFERROR(IF(\$B\$2="","",IF(HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROW()-7,FALSE)=0,"",HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROW()-7,FALSE))),"")
0

Commented:
try:

=IF(\$B\$2="","",IFERROR(IF(HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROWS(\$A\$9:\$A9)+1,FALSE)=0,"",HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROWS(\$A\$9:\$A9)+1,FALSE)),""))
0

Author Commented:
The reason I selected your soultion was it was returning the dates I was expecting. The other solution did not.
Thanks to all.
0

Commented:
Actually, I just compared my solution with ssaqibh's solution, and both give same results....
0

Commented:
Added a date row and other changes.  Attachement included.  Here's the formula for the second row of your important dates (as an example.)

=IF(ISERROR(HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROW(\$B\$2),FALSE))=TRUE,"",IF(HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROW(\$B\$2)+(A16-1),FALSE)=0,"",HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROW(\$B\$2)+A16-1,FALSE)))

="if the whole formula is invalide then nothing", "if the formula delivers zero then nothing", "deliver results."

The ROW(\$b\$2) gives the row number of your month headers.  The 16 gives the row number of your results.  By using these variables you can move stuff around without breaking it.

lvbarnes
Copy-of-HLookup-problem.xlsm
0

Author Commented:
Folks,
The best solution of the three was lvbarnes. I revisited the other two solutions and determined that the row() - was wrong for both, giving me dates such as 01/12/2010 for the 12th month in addition to the correct date of 12/3/2010. Once I adjusted for the row count I got the information I was looking for. Ivbarnes's solution worked as presented without any changes.
I truly thought and believed that the solution I accepted was the best at the time and hopefully, no one took offense to my decision. I'll try harder to avoid these situations going forward. My time is limited here at work so I am rushed.
Thanks to all and I appreciate the Experts at Expert Exchange very much!
0

Commented:
I still don't see a difference... but hey...that's just me.
0

Commented:
=IF(\$B\$2="","",IFERROR(IF(HLOOKUP(\$B\$2,\$C\$2:\$F\$5,
ROWS(\$A\$9:\$A9)+1 <-- Changed to ROW(\$B\$2)+(A16-1),
,FALSE)=0,"",HLOOKUP(\$B\$2,\$C\$2:\$F\$5,ROWS(\$A\$9:\$A9)+1,FALSE)),""))

Below the calendar date table he had 3 rows for the important dates.  When the above formula was dragged down the ROWS(\$A\$9:\$A9)+1 returned the same date from the first row.  I added a row number column to his resultset and changed the +1 to a (Result number -1 ) so that it was dynamic and he could add/remove rows.  (Although the important dates will most likely by turned into one date string at some point.)
0

Commented:
Where is the difference in results in our solutions?... see attached.
Copy-of-HLookup-problem-1.xlsm
0

Author Commented:
Thanks for everyones continued interest.
I hope I have not affended anyone - I've always tried to be fair and honest.
0

Commented:
fh_freese:  No worries.  Debating solutions is one of the ways that EE members learn and the EE users get the benefit.  I didn't look at NB_VC's solution but, because he brought it up I have and learned something from it.  I've never used a row range before and he did.  His use of that row range eliminates my need for the additional results column.
0

Commented:
Yes, fh_freeze, lvbarnes is correct.  It's just a point of discussion and I was just looking to clarify and understand why you say some solutions work and others don't.  Please don't think that you have offended anyone.
0

Author Commented:
Thanks to all of you!
0

Commented:
Yikes!!!
NB_VC
791,247 Expert Points
57,560 Points this month
0

Author Commented:
Folks,
This morning I determined that there were indeed three solutions. In fairness to all is there a way to change the point distribution?
0

EngineerCommented:
Click on the yellow tag called "Request attention" at the bottom right corner of your question
0

Author Commented:
thanks to all
I've corrected my error in distributing points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.