Trying to Make XLOOKUP Work with Single Cell Array

jase71ds

Board Regular
Joined
Oct 23, 2006
Messages
137
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use XLOOKUP to reference a single cell (array) and return a value.

Example
A1 = .6
B1 = {0, .1, .6, .9, 1}
XLOOKUP( A1, B1, B1, , , -1 )

So if A1 were .6, then .6 would be returned
But if A1 were .5, then .1 would be returned

I understand that I could take cell B1 and stretch it out from B1 to B5, but I'm wondering if XLOOKUP can work with a single cell array.

Anyway, I've had no luck getting XLOOKUP to work with a single cell array. Am I doing something wrong, or is this just not possible?
Thanks.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Excel Formula:
=XLOOKUP(A1,B1#,B1#,,-1)
Hmmmm...
I get a #REF error.
To be clear, in B1, I literally just typed "{0, .1, .6, .9, 1}" (without the quotes)
Isn't this the correct way to enter an array value?
Any thoughts?
 
Upvote 0
I see. If you put in the '=' before it all, it will make an array from B1 to G1 - and then it will work.

If you can't SPILL into those other cells - then it is a different story that I can think about...
 
Upvote 0
B1 is just a text string, not an array, so you either need to split it into separate cells, or coerce into an array within the formula
 
Upvote 0
B1 is just a text string, not an array, so you either need to split it into separate cells, or coerce into an array within the formula
Agree. Any thoughts on how to coerce it?

By the way, when I hardcode the formula as =XLOOKUP( A1, {0, .1, .6, .9, 1}, {0, .1, .6, .9, 1}, , -1 )
It works.
But if i put {0, .1, .6, .9, 1} in B1, and use your method of =XLOOKUP(A1,B1#,B1#,,-1) I get the #REF error.
 
Upvote 0
This is a bit funny. Take out the {}:

MrExcelPlayground4.xlsx
AB
10.60, .1, .6, .9, 1
20.6
Sheet31
Cell Formulas
RangeFormula
A2A2=XLOOKUP(A1,FILTERXML("<t><s>"&SUBSTITUTE(B1,",","</s><s>")&"</s></t>","//s"),FILTERXML("<t><s>"&SUBSTITUTE(B1,",","</s><s>")&"</s></t>","//s"),"",-1)
 
Upvote 0
Solution
This is a bit funny. Take out the {}:

MrExcelPlayground4.xlsx
AB
10.60, .1, .6, .9, 1
20.6
Sheet31
Cell Formulas
RangeFormula
A2A2=XLOOKUP(A1,FILTERXML("<t><s>"&SUBSTITUTE(B1,",","</s><s>")&"</s></t>","//s"),FILTERXML("<t><s>"&SUBSTITUTE(B1,",","</s><s>")&"</s></t>","//s"),"",-1)
Holy cow!!
It works, but it's scary quantum physics or something :)
I'll need to study this.
Thanks!!!
 
Upvote 0
I'm afraid of the FILTERXML function, but it does some things neatly.
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,043
Members
449,092
Latest member
ikke

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