How to adjust a 'defined-name' array based on whether there are comma-separated numbers in cell(s) of the array?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
578
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have defined names corresponding to certain ranges like the one below where Info!$E$1 specifies the bottom of the array (through a SUMPRODUCT formula that detects the last row of the column that has data):

AINFOcJ=INDIRECT("Info!$J$3:$J$"&Info!$E$1)

Up until now, this column J included only numbers 1 or 2 which are selectable from dropdown menus in each cell of column J. However, I want to start adding "1,2" as another option in these dropdown menus, so now the menus will show three options: "1", "2", and "1,2".

Th problem now is that "1,2" is not a number, so it will completely mess up all calculations that utilize the AINFOcJ array. So now I need a way of adjusting AINFOcJ definition only if commas are found anywhere in the range of J3:Jn such that all "1,2" instances are dissected into 1 and 2 and shown right after each other at the correct order within the rest of the array. So basically this will result in an expanded array which I have shown in the attached XL2BB. the top arrays are original ranges and bottom arrays are the result of the defined names. The left arrays are the normal scenario where there are no instances of "1,2". The right array has two instances of "1,2" which I have shown dissected at the bottom.

So, how do I need to modify the definition of my array to take care of this situation?

Book2
ABCDE
1
211
322
422
511
621,2
722
822
911,2
1011
1122
12
13
1411
1522
1622
1711
1821
1922
2022
2112
2211
2322
241
252
26
Sheet1



Thanks for any input!
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
What about: =FILTERXML("<x><y>"&SUBSTITUTE(TEXTJOIN(",",,Info!$J$3:INDEX(Info!$J:$J,Info!$E$1)),",","</y><y>")&"</y></x>","//y")

And if you have the new TEXTSPLIT function (I'm still waiting) you could use that instead of the FILTERXML construction.
 
Last edited:
Upvote 0
Solution
OMG, it works so well!!! Thank you so much! 🤗

Today I got solutions for two complex questions, so feeling super happy 😅

I'm also still waiting for those 14 or so new functions, but no idea when they're coming.
 
Upvote 0
Thanks! Also I realized I'm gonna have to apply this filtering concept to a more complex situation, i.e. the columns flanking J, so that when J contains any "1,2", they would need to expand accordingly by duplicating every cell which is across from a "1,2"-containing cell in J 😂 But let me first think about it a little more, and if I get stuck (which I'll probably do), I'll post here with some more details and an XL2BB.

Cheers 🥂
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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