Formula to aggregate emails if values in other cells match certain text

Dogboydan

New Member
Joined
Aug 27, 2015
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hi all, using Excel 2016, I'm trying to create a formula that will allow a user to select multiple criteria from some columns, and it will return the email address if there is a match in any of the columns. So far I have the following code working in that it returns the correct email addresses, but is returning the email address twice if it matches both criteria:

=IFERROR(INDEX($B$5:$B$100, AGGREGATE(15, 6, (ROW($S$5:$Y$100)-ROW($S$5)+1)/((ISNUMBER(SEARCH($Z$2, $S$5:$Y$100))) + (ISNUMBER(SEARCH($Z$3, $S$5:$Y$100)) * (COUNTIF($Z$6:Z6, INDEX($B$5:$B$100, AGGREGATE(15, 6, (ROW($S$5:$Y$100)-ROW($S$5)+1)/ISNUMBER(SEARCH($Z$2, $S$5:$Y$100)), ROW(1:1))))=0))), ROW(1:1))), "")

I'm not able to upload a sample file due to personal info and restrictions, but I've created a table below to represent the data

Email (B4)Columns C-RSite 1 (S4)Site 2 (T4)Site 3 (U4)Site 4 (V4)Site 5 (X4)Site 6 (Y4)
bobbarker@email.comNew YorkSeattlePhiladelphiaAustin
stevemadden@email.comMiamiChicagoSeattlePhiladelphiaAnchorageAustin
jimcarrey@email.comNew YorkHoustonChicago
fredflintstone@email.comMiamiNew YorkHoustonDallas

Now, the formula is entered into Z7 as an array and dragged down 100 cells. It references Values within cells Z2 and Z3 that it searches for. So in this example, assume Z2=Seattle, and Z3=Miami.

Right now the formula returns the following:
bobbarker@email.com
stevemadden@email.com
stevemadden@email.com
fredflintstone@email.com

This is technically correct in that jimcarrey@email.com is skipped as it doesn't match any, but it reports stevemadden@email.com twice as it matches both criteria.

How do I update it so that if the email already exists on the list, it is skipped/only listed once? I'd like to try and save users the need to have to remove duplicates manually. Thank you.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Maybe something like ...

Teste 02.xlsx
STUVWXYZ
1
2Seattle
3Miami
4Site 1Site 2 Site 3Site 4Site 5Site 6
5New YorkSeattlePhiladelphiaAustin
6MiamiChicagoSeattlePhiladelphiaAnchorageAustin
7New YorkHoustonChicagobobbarker@email.com
8MiamiNew YorkHoustonDallasstevemadden@email.com
9fredflintstone@email.com
10 
Planilha3
Cell Formulas
RangeFormula
Z7:Z10Z7=IFERROR(INDEX(B$5:B$100,AGGREGATE(15,6,(ROW(S$5:Y$100)-ROW(S$5)+1)/(MMULT(--ISNUMBER(MATCH(S$5:Y$100,$Z$2:$Z$3,0)),{1;1;1;1;1;1;1})>0),ROWS(Z$7:Z7))),"")


M.
 
Upvote 0
Solution
Maybe something like ...

Teste 02.xlsx
STUVWXYZ
1
2Seattle
3Miami
4Site 1Site 2 Site 3Site 4Site 5Site 6
5New YorkSeattlePhiladelphiaAustin
6MiamiChicagoSeattlePhiladelphiaAnchorageAustin
7New YorkHoustonChicagobobbarker@email.com
8MiamiNew YorkHoustonDallasstevemadden@email.com
9fredflintstone@email.com
10 
Planilha3
Cell Formulas
RangeFormula
Z7:Z10Z7=IFERROR(INDEX(B$5:B$100,AGGREGATE(15,6,(ROW(S$5:Y$100)-ROW(S$5)+1)/(MMULT(--ISNUMBER(MATCH(S$5:Y$100,$Z$2:$Z$3,0)),{1;1;1;1;1;1;1})>0),ROWS(Z$7:Z7))),"")


M.
That works! Thank you very much :)
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
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