Vlookup with indirect returning 0, when value is present

ChrisTag1

New Member
Joined
Jan 13, 2020
Messages
11
Office Version
  1. 2016
Platform
  1. Windows
Hey everyone,

Looking for some help again. I have a formula..... =IFERROR(IF($G$8="Primary",VLOOKUP(I$8,INDIRECT("PrimaryDailyRange"),2,0),IF($G$8="Secondary",VLOOKUP(I$8,INDIRECT("SecondaryDailyRange"),2,0))),0),
that works exactly how I need it to in one worksheet. The next worksheet is almost exactly the same as the first, except I am getting the data from a different named range. I am trying to use this same formula with the new named range, but it returns 0 instead of the data in the referenced cell. =IFERROR(IF($G$8="Primary",VLOOKUP(U$8,INDIRECT("PrimaryWeeklyRange"),2,0),IF($G$8="Secondary",VLOOKUP(U$8,INDIRECT("SecondaryWeeklyRange"),2,0))),0)
What am I doing wrong? I don't understand why it works for one named range and not for the other.

Any ideas?

Thanks all.
 

Attachments

  • DWOR.png
    DWOR.png
    79 KB · Views: 26
  • primaryrange.png
    primaryrange.png
    136 KB · Views: 27
  • SWOR.png
    SWOR.png
    52.5 KB · Views: 30
  • Primaryweek.png
    Primaryweek.png
    161.1 KB · Views: 29

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Don't know but your primaryweekly range seems to have a space as the first part of the data, in which case it maybe the IFEEROR is triggered which is why the zero. If you made 0 into a word you would see its the error trap
 
Upvote 0
Looks to me like the 0 it's returning is likely to be the result of the IFERROR function.

Try taking the IFERROR out, or using the inline evaluation of the formula to check for errors.
My guess would be that the date you're looking up doesn't actually exist in the lookup table (the years are not displayed, so can't be certain one way or the other)
 
Upvote 0
Also - as far as I see the use of Indirect here is redundant (you can just use the range name directly in the vlookup formula).

However, you could simplify your formula (and make it more efficient) by leveraging the naming convention and the INDIRECT function;

=IFERROR(VLOOKUP(U$8,INDIRECT($G$8&"WeeklyRange"),2,0),0)

This concatenates the value from G8 (Primary or Secondary) with "WeeklyRange" (common between the two range names), and feeds it into the INDIRECT function to get a reference to the relevant range.

This should be a more efficient option, where your formula is doing two cell comparisons (the test part of the IF statements) and two VLOOKUPS (Excel evaluates every element of a formula), where the above does one INDIRECT and one VLOOKUP.
 
Upvote 0
FatBoyClam,
I redid the formula without the IFERROR, and the error I am getting is #NA. I thought it was the dates too, but the dates are all the same in every worksheet. So in the first worksheet, where the formula works, it is looking up the same dates as in the second worksheet. So I am really at a loss as to why I can't get my formula to return a value that I can plainly see is in the cell.
 
Upvote 0
FatBoyClam,
You were correct about the date. In the 2 tables being referenced in my formula, the date was a text instead of a date. (ie "10/28/19" instead of 43766). I have been so used to the answers to my problems being complicated that I completely overlooked the obvious.

Cheers
 
Upvote 0
Glad you got to the answer Chris (y)
Hope the shortened formula works for you, if you try it out.
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,592
Members
452,653
Latest member
craigje92

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