Extract Unique values, multiple length criteria

bsquad

Board Regular
Joined
Mar 15, 2016
Messages
194
I used to work a ton with these types of unique extraction array formulas, but am having some trouble remembering if I am even going about this the right way. The formula below is attempting to extract/index a unique value if its length is equal to 18 or 26 or 28.

This workbook is large, it has lots of formulas and vba code, I would like to not use Application.Calculation = xlCalculationManual in my code, and I am avoiding all Volatile formula functions.

the Array formula

Code:
=IF(ROWS($N$17:N17)>SUMPRODUCT(--(LEN($B$17:$B$26)=18),--(LEN($B$17:$B$26)=26),--(LEN($B$17:$B$26)=28)),"",INDEX($B$17:$B$26,SMALL(IF((LEN($B$17:$B$26)=18)*(LEN($B$17:$B$26)=26)*(LEN($B$17:$B$26)=28),ROW($B$17:$B$26)-ROW($B$17)+1),ROWS($N$17:N17))))
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
In N16 control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(1-($B$17:$B$26=""),IF(ISNUMBER(MATCH(LEN($B$17:$B$26),{18,26,28},0)),MATCH($B$17:$B$26,$B$17:$B$26,0))),ROW($B$17:$B$26)-ROW($B$17)+1),1))

In N17 control+shift+enter, not just enter, and copy down:

=IF(ROWS($N$17:N17)>$N$16,"",INDEX($B$17:$B$26,SMALL(IF(FREQUENCY(IF(1-($B$17:$B$26=""),IF(ISNUMBER(MATCH(LEN($B$17:$B$26),{18,26,28},0)),MATCH($B$17:$B$26,$B$17:$B$26,0))),ROW($B$17:$B$26)-ROW($B$17)+1),ROW($B$17:$B$26)-ROW($B$17)+1),ROWS($N$17:N17))))
 
Upvote 0
Aladin, thanks so much for the reply; its appreciated. The formula you provided works great!

I could essentially replace the $N$16 with something like a =IF(ROWS($N$17:N17)>SUMPRODUCT(--($B$17:$B$26<>"")) ?

I see what you are doing with the first formula and would agree it would be the most precise; but it wouldn't necessarily be essential in order to run the 2nd formula if I used something like a SUMPRODUCT correct?
 
Upvote 0
Aladin, thanks so much for the reply; its appreciated. The formula you provided works great!

You are welcome.

I could essentially replace the $N$16 with something like a =IF(ROWS($N$17:N17)>SUMPRODUCT(--($B$17:$B$26<>"")) ?

I see what you are doing with the first formula and would agree it would be the most precise; but it wouldn't necessarily be essential in order to run the 2nd formula if I used something like a SUMPRODUCT correct?

No. FREQUENCY version is faster.

If you insist on having a single formula...

Select B17:B26 and name the selection Data in the Name Manager.
Define also Ivec in the Name Manager as referring to:

=ROW(Data)-ROW(INDEX(Data,1,1))+1

Now we can the following single formula. Control+shift+enter and copy down:

=IF(ROWS($N$17:N17)>SUM(IF(FREQUENCY(IF(1-(Data=""),IF(ISNUMBER(MATCH(LEN(Data),{18,26,28},0)),MATCH(Data,Data,0))),Ivec),1)),"",INDEX(Data,SMALL(IF(FREQUENCY(IF(1-(Data=""),IF(ISNUMBER(MATCH(LEN(Data),{18,26,28},0)),MATCH(Data,Data,0))),Ivec),Ivec),ROWS($N$17:N17))))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,755
Members
449,049
Latest member
excelknuckles

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