Microsoft Excel
--
Questions
--
Followers
Top Experts
In F4, I have the formula:
=VLOOKUP(E4,INDIRECT($A$1&
There is a dynamic range named Q_1_Scale, and if I do something like:
=SUM(Q_1_Scale)
I get the right answer.
Also, if I do:
=VLOOKUP(E4,Q_1_Scale,2,TR
I get the right answer.
Do INDIRECT() and dynamic ranges just not play well together?
Patrick
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
#Ref would indicate that your cell A1 has additional spaces or something other than "Q_1" Â
#N/A would indicate that your lookup value is outside of the range
The problem might be the dynamic range. They have some special qualities that make them a bit more difficult to deal with. What is the name reference? You might also try setting Q_1_Scale to a static range and see if the results improve.
Kevin
It's a #REF error.
Regards,
Patrick






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
It appears that I am being done in by those "special qualities". Â When I make Q_1_Scale static, the INDIRECT() approach
works just fine.
Overall, it's OK--it would have made my current workbook project a tiny bit more convenient to use INDIRECT with the
dynamic ranges, but my alternate VLOOKUP() construction will do the job.
I'll leave this open a bit longer, to see if Brad, Dave, Matt, or someone else has anything to offer...
Regards,
Patrick
I just got the same exact results as you with the same tests. I'll see if I can come up with something for you.
A question: why do you need the name to be dynamic?
Kevin
It's a long story, but I'll try to be brief :)
I am on a project where a client has lots of different operations stats being compiled, and each stat has its own scaling
and scoring rules. Â The scoring rules are stored in a big lookup table, and instead of having different tables for each
stat, all the stats' rules are in a single lookup table. Â I am using an ID string to identify the rules for any given stat.
So, for example, Q_1 is simply the first "quality" stat being tracked, and the lookup table will have n records saying
how to score for different values of the stat.
Since the scoring rules are expected to change often over the next 12 months, I figured this construction would make
it easier to do updates.
The stats themselves are being computed on individual worksheets, with some commonality across all the worksheets.
I was hoping to have the formulae on the various worksheets that handle the scoring calc to look the same everywhere,
and just have A1 on each worksheet hold the stat ID.
Confused yet? :)
Regards,
Patrick

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Kevin
You got it.
Regards,
Patrick
You are the man!
I had to make a slight tweak, changing:
  Row = Application.Match(SearchVa
to:
  Row = Application.Match(SearchVa
I did this because I need to emulate VLOOKUP's "close match" capability.
Thanks a bunch!
Regards,
Patrick






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I guess for posterity the function could have an optional fourth argument that controls how MATCH will operate...
Regards,
Patrick
Kevin
For the record, here is the function in the form I implemented in my project:
Public Function VLookupSpecial(ByVal SearchValue As Variant, ByVal SourceRange As String, _
  ByVal ColumnOffset As Long, Optional ByVal MatchType As Long = 0) As Variant
  Dim Row As Long
    Â
  On Error Resume Next
  Row = Application.Match(SearchVa
  On Error GoTo 0
  If Row > 0 Then
    VLookupSpecial = Range(SourceRange).Columns
  Else
    VLookupSpecial = CVErr(xlErrNA)
  End If
End Function
In my formulae, I am using 1 for the optional fourth argument.
Pleased as punch,
Patrick

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
This issue came up in VBAX, in case you are interested:
http://www.vbaexpress.com/forum/showpost.php?p=25408&postcount=48
Regards,
Patrick
XLD does not have it quite right. It is not what the OFFSET or INDIRECT functions return but rather what the named range mechanism returns. Consider this example:
Cell A1 contains the string "B1:B10" and the cells B1:B10 contain the letters a through j. There is a named range, "Test" that contains the following formula:
=OFFSET(Sheet1!A1,0,0)
Cell C1 contains:
=MATCH("i",INDIRECT(OFFSET
Cell C2 contains:
=MATCH("i",INDIRECT(Test),
Cell C1 resolves to 9 while C2 resolves to #REF!
As you can see the ONLY difference between cells C1 and C2 is the indirection of the OFFSET function behind the name. Thus we can conclude that the name resolution function is the culprit and not the OFFSET or INDIRECT function. In other words, don't expect dynamic range names to ever return a range reference, they will always return values. Then the question becomes: What does the next function in line expect? VLOOKUP and MATCH for example insist on a range reference which is why they fail. SUM on the hand will accept either a range reference or values.
Kevin
Microsoft Excel
--
Questions
--
Followers
Top Experts
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.