SOLVED

Excel Filter Function - Use Same Formula Across Multiple Cells

%3CLINGO-SUB%20id%3D%22lingo-sub-1877806%22%20slang%3D%22en-US%22%3EExcel%20Filter%20Function%20-%20Use%20Same%20Formula%20Across%20Multiple%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1877806%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%E2%80%99m%20looking%20for%20some%20guidance%20on%20using%20the%20Excel%20Filter%20function%20and%20making%20it%20so%20it%20available%20to%20use%20in%20other%20cells%20within%20the%20same%20column.%3C%2FP%3E%3CP%3EI%20have%20the%20following%20formula%20that%20looks%20for%20a%20value%20in%20A1%20and%20produces%20a%20list%20from%20whatever%20is%20added%20in%20there.%20E.g.%20user%20enters%20%E2%80%98Am%E2%80%99%20and%20the%20list%20it%20returns%20is%20America%2C%20Amazon%E2%80%A6.%3C%2FP%3E%3CP%3EFormula%20is%20in%20say%20B1%2C%20Map%5BName%5D%20is%20a%20list%20of%20countries%E2%80%A6%3C%2FP%3E%3CP%3E%3DSORT(FILTER(Map%5BName%5D%2CISNUMBER(SEARCH(Item!A1%2C%20Map%5BName%5D))%2C%22Not%20Found%22))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20great%2C%20however%20I%20want%20the%20formula%20to%20work%20for%20the%20rows%20after%20A1%20(row%201)%2C%20e.g.%20A2%20(row%202)%2C%20A3%20(row%203)%2C%20etc.%20I%20have%20been%20trying%20to%20use%20OFFSET%20and%20COUNTA%20to%20somehow%20look%20at%20the%20next%20row%20down%20to%20no%20avail.%20Each%20row%20must%20have%20a%20country%20in%20there%20as%20mandatory%20field%2C%20so%20was%20thinking%20that%20would%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20really%20appreciated.%20A%20caveat%20would%20be%20that%20I%20can't%20use%20VBA!%20Thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1877806%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1878106%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Filter%20Function%20-%20Use%20Same%20Formula%20Across%20Multiple%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1878106%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F865719%22%20target%3D%22_blank%22%3E%40NareshTakashi%3C%2FA%3E%26nbsp%3B%20I%20don't%20understand%20what%20you%20mean%20by%20%22%3CSPAN%3Ework%20for%20the%20rows%20after%20A1%22.%26nbsp%3B%20Do%20you%20mean%20you%20want%20to%20have%20a%20filtered%20list%20for%20each%20value%20in%20column%20A%20or%201%20filtered%20list%20base%20on%20a%20combination%20of%20values%20in%20A%20or%20something%20else%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESo%20to%20have%20a%20list%20for%20each%20value%20in%20A%20you%20have%20the%20spillage%20problem%20but%20you%20could%20use%20TRANSPOSE()%20around%20your%20formula%20so%20instead%20of%20spilling%20down%20the%20column%20it%20spills%20to%20the%20right%20across%20columns%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESo%20to%20incorporate%20multiple%20options%20to%20create%20a%20combined%20filtered%20list%20you%20can%3A%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DSORT(FILTER(Map%5BName%5D%2CISNUMBER(SEARCH(Item!A1%2C%20Map%5BName%5D))%2BISNUMBER(SEARCH(Item!A2%2C%20Map%5BName%5D))%2C%22Not%20Found%22))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ethat%20is%20relatively%20easy%20to%20read%20but%20if%20you%20start%20to%20have%20a%20lot%20of%20items%20in%20column%20A%20that%20can%20get%20very%20large%20so%20you%20can%20also%20do%20this%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DFILTER(Map%5BName%5D%2CTRANSPOSE(MMULT(SEQUENCE(1%2CROWS(A1%3AA3))%2C--ISNUMBER(SEARCH(A1%3AA3%2CTRANSPOSE(CHOOSE(SEQUENCE(1%2CROWS(A1%3AA3))%2CMap%5BName%5D%2CMap%5BName%5D%2CMap%5BName%5D))))))%2C%22none%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThis%20is%20for%203%20cells%20in%20A%20but%20can%20be%20expanded%20to%20larger%20number%20of%20rows%20in%20A%20BUT%20as%20you%20might%20see%20I%20had%20to%20repeat%20Map%5BName%5D%203x%20and%20you%20would%20have%20to%20repeat%20it%20that%20number%20of%20times.%26nbsp%3B%20Since%20you%20have%20to%20manually%20manipulate%20this%20formula%20for%20different%20range%20sizes%20you%20could%20use%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DFILTER(Map%5BName%5D%2CTRANSPOSE(MMULT(%7B1%2C2%2C3%7D%2C--ISNUMBER(SEARCH(A1%3AA3%2CTRANSPOSE(CHOOSE(%7B1%2C2%2C3%7D%2CMap%5BName%5D%2CMap%5BName%5D%2CMap%5BName%5D))))))%2C%22none%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20adjust%20the%20%7B1%2C2%2C3%7D%20to%20also%20match%20how%20many%20rows%20in%20A%20you%20are%20using.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%20another%20volunteer%20here%20can%20chime%20in%20with%20a%20more%20elegant%20alternative.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1878470%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Filter%20Function%20-%20Use%20Same%20Formula%20Across%20Multiple%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1878470%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F865719%22%20target%3D%22_blank%22%3E%40NareshTakashi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConceptually%2C%20you%20appear%20to%20be%20looking%20to%20produce%20an%20array%20or%20arrays%20which%2C%20sadly%2C%20Excel%20does%20not%20traditionally%20support.%26nbsp%3B%20As%20was%20suggested%2C%20the%20TRANSPOSE%20function%20would%20allow%20your%20list%20of%20matched%20country%20names%20to%20spill%20horizontally%2C%20so%20allowing%20multiple%20lists%20to%20be%20stacked%20vertically.%26nbsp%3B%20This%20would%2C%20though%2C%20require%20the%20formula%20to%20be%20copied%20down.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20761px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F233010iB524210CD0842C0F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EDressed%20up%2C%20the%20same%20formula%20could%20be%20written%20in%20the%20form%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%20%20matches%2C%20ISNUMBER(SEARCH(%40PartialName%2C%20Map%5BName%5D))%2C%0A%20%20matchingNames%2C%20FILTER(Map%5BName%5D%2C%20matches%2C%22Not%20Found%22)%2C%0A%20%20TRANSPOSE(matchingNames)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1879189%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Filter%20Function%20-%20Use%20Same%20Formula%20Across%20Multiple%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1879189%22%20slang%3D%22en-US%22%3E%3CP%3EI%20don't%20have%20the%20FILTER%20or%20SORT%20functions%2C%20so%20I%20can't%20test%20with%20those%20particular%20functions.%20But%2C%20you%20might%20try%20using%20textjoin%20to%20join%20your%20arrays%20and%20then%20filter%20again%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3DFILTERXML(%22%3CL%3E%3CI%3E%22%26amp%3BTEXTJOIN(%22%3C%2FI%3E%3CI%3E%22%2CTRUE%2CIF(ISNUMBER(SEARCH(TRANSPOSE(A1%3AA2)%2CMAP%5BName%5D))%2CMAP%5BName%5D%2C%22%22))%26amp%3B%22%3C%2FI%3E%3C%2FL%3E%22%2C%22%2F%2FI%22)%3CBR%20%2F%3E%3CBR%20%2F%3EAnd%2C%20you'll%20likely%20need%20to%20wrap%20it%20with%20iferror%20(or%20some%20conditional%20test)%20in%20case%20none%20of%20the%20items%20exist.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1884224%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Filter%20Function%20-%20Use%20Same%20Formula%20Across%20Multiple%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1884224%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3EReally%20appreciate%20your%20comments.%26nbsp%3BUsing%20Transpose%20with%20the%20formula%20copied%20down%20a%20couple%20of%20hundred%20rows%20did%20the%20job.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20thing%20to%20note%2C%20is%20that%20in%20my%20scenario%20I%20needed%20to%20Protect%20the%20sheet%2C%20to%20stop%20users%20messing%20around%20with%20the%20structure.%20In%20doing%20so%2C%20when%20using%20the%20filter%20functionality%20the%20search%20will%20chug%20along%20(my%20laptop%20is%20Excel%2064%2C%20I7%2C%2016GB%20RAM).%20I%20won't%20be%20telling%20users%20that%20they%20can%20filter%20do%20to%20this%20performance%20issue%20and%20just%20use%20the%20drop%20down.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20all%20your%20help!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1884698%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Filter%20Function%20-%20Use%20Same%20Formula%20Across%20Multiple%20Cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1884698%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F865719%22%20target%3D%22_blank%22%3E%40NareshTakashi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20wouldn't%20have%20anticipated%20problems%20especially%20with%20the%20machine%20spec%20you%20outline.%3C%2FP%3E%3CP%3EIn%20my%20case%2C%20I%20asked%20for%20trouble%20by%20importing%20geographical%20data%20from%20the%20internet%2C%20so%20other%20things%20com%20into%20play.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hello,

I’m looking for some guidance on using the Excel Filter function and making it so it available to use in other cells within the same column.

I have the following formula that looks for a value in A1 and produces a list from whatever is added in there. E.g. user enters ‘Am’ and the list it returns is America, Amazon….

Formula is in say B1, Map[Name] is a list of countries…

=SORT(FILTER(Map[Name],ISNUMBER(SEARCH(Item!A1, Map[Name])),"Not Found"))

 

It works great, however I want the formula to work for the rows after A1 (row 1), e.g. A2 (row 2), A3 (row 3), etc. I have been trying to use OFFSET and COUNTA to somehow look at the next row down to no avail. Each row must have a country in there as mandatory field, so was thinking that would work.

 

Any help would be really appreciated. A caveat would be that I can't use VBA! Thanks.

5 Replies

@NareshTakashi  I don't understand what you mean by "work for the rows after A1".  Do you mean you want to have a filtered list for each value in column A or 1 filtered list base on a combination of values in A or something else?

So to have a list for each value in A you have the spillage problem but you could use TRANSPOSE() around your formula so instead of spilling down the column it spills to the right across columns

So to incorporate multiple options to create a combined filtered list you can:

 

 

=SORT(FILTER(Map[Name],ISNUMBER(SEARCH(Item!A1, Map[Name]))+ISNUMBER(SEARCH(Item!A2, Map[Name])),"Not Found"))

 

 

that is relatively easy to read but if you start to have a lot of items in column A that can get very large so you can also do this:

 

 

=FILTER(Map[Name],TRANSPOSE(MMULT(SEQUENCE(1,ROWS(A1:A3),1,0),--ISNUMBER(SEARCH(A1:A3,TRANSPOSE(CHOOSE(SEQUENCE(1,ROWS(A1:A3),1,0),Map[Name])))))),"none")

 

 

This is for 3 cells in A but can be expanded to larger number of rows in A.  NOTE: this will include any Name in Map that has any value in the col A range anywhere in that Name so if ANY included cell in the col A range is blank it will return all of the Names

Best Response confirmed by NareshTakashi (New Contributor)
Solution

@NareshTakashi 

Conceptually, you appear to be looking to produce an array or arrays which, sadly, Excel does not traditionally support.  As was suggested, the TRANSPOSE function would allow your list of matched country names to spill horizontally, so allowing multiple lists to be stacked vertically.  This would, though, require the formula to be copied down.

image.png

Dressed up, the same formula could be written in the form

= LET(
  matches, ISNUMBER(SEARCH(@PartialName, Map[Name])),
  matchingNames, FILTER(Map[Name], matches,"Not Found"),
  TRANSPOSE(matchingNames) )

I don't have the FILTER or SORT functions, so I can't test with those particular functions. But, you might try using textjoin to join your arrays and then filter again:

=FILTERXML("<L><I>"&TEXTJOIN("</I><I>",TRUE,IF(ISNUMBER(SEARCH(TRANSPOSE(A1:A2),MAP[Name])),MAP[Name],""))&"</I></L>","//I")

And, you'll likely need to wrap it with iferror (or some conditional test) in case none of the items exist.

@Peter Bartholomew  @mtarler @JMB17 

 

Hi All,

Really appreciate your comments. Using Transpose with the formula copied down a couple of hundred rows did the job.

 

One thing to note, is that in my scenario I needed to Protect the sheet, to stop users messing around with the structure. In doing so, when using the filter functionality the search will chug along (my laptop is Excel 64, I7, 16GB RAM). I won't be telling users that they can filter do to this performance issue and just use the drop down.

 

Thanks for all your help!

 

 

@NareshTakashi 

I wouldn't have anticipated problems especially with the machine spec you outline.

In my case, I asked for trouble by importing geographical data from the internet, so other things com into play.