Return Array where value in another Array.

ko1967

New Member
Joined
Jan 3, 2017
Messages
27
I have an array (lets call it Array1) and another array (lets call it Array2) as follows.

Array1 = {A,B,C,D}
Array2 = {A,C}

I'm trying to return an array (same length as Array1) where the value will be true if the item in Array1 is found in Array2.

Essentially from the above I want to return {TRUE, FALSE, TRUE, FALSE} because A and C are in Array2 and B and D are not. Every solution I've tried returns an array of 2 elements not 4. I'm on office 365 so I have access to all the new dynamic array functions.

Thanks.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Are these "arrays" one dimensional VBA arrays or cell range arrays?

Can you show us how the arrays are populated?

Is Array2 always going to contain less elements than Array1?
 
Upvote 0
The arrays are contained in cell ranges and yes, Array2 always has less elements than Array1. I'm looking for a formula solution, not a VBA solution.
 
Upvote 0
Is this what you mean?

+Fluff New.xlsm
JKL
2AATRUE
3BCFALSE
4CTRUE
5DFALSE
Master
Cell Formulas
RangeFormula
L2:L5L2=ISNUMBER(MATCH(J2:J5,K2:K3,0))
Dynamic array formulas.
 
Upvote 0
Is this what you mean?

+Fluff New.xlsm
JKL
2AATRUE
3BCFALSE
4CTRUE
5DFALSE
Master
Cell Formulas
RangeFormula
L2:L5L2=ISNUMBER(MATCH(J2:J5,K2:K3,0))
Dynamic array formulas.
If you are correct in setup and the type of formula (multi-cell selected, array entered) the OP wants, then this should also work...

=COUNTIF(K2:K3,J2:J5)>0
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Not done quite yet, if you don't mind. What I provided was a very simple example of a more complex problem.

Let's assume the following.

=COUNTIFS({1,3},{1,2,3,4}) returns {1,0,1,0}
=COUNTIFS(K2:K3,J2:J5) also returns {1,0,1,0}

So COUNTIFS evalutes the 2 ranges into 2 arrays which we all know.

So lets set X1 = FILTER(K2:K4,P2:P4=1) such that the result is a spilled array returning {1,3} which is the same as the values in the array K2:K3.

Now lets set Y1 =COUNTIFS(X1#,J2:J5) and it returns {1,0,1,0} as expected.

However, set Z1 =COUNTIFS(FILTER(K2:K4,P2:P4=1),J2:J5) and Excel will issue an error (There is a problem with the formula) when you press enter. You can use F9 to evaluate both the first and second argument of the COUNTIFS function and it still will issue the same error when you press enter.

@Rick Rothstein ... any clue what the issue is here before I report it to Microsoft as a bug?

@Fluff ... good news is =ISNUMBER(MATCH(J2:J5,FILTER(K2:K4,P2:P4=1),0)) works as expected.

Fun w/ dynamic arrays :)
 
Upvote 0
Countifs needs a range, not an array.
Also this
=COUNTIFS({1,3},{1,2,3,4})
does not work for me, for the same reason.
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,673
Members
449,463
Latest member
Jojomen56

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