Alphabetizing names while removing certain words from cells

RonOliver

Board Regular
Joined
Aug 30, 2022
Messages
99
Office Version
  1. 365
Platform
  1. Windows
Hi everyone. Hope you're having a lovely day.

I found a formula on the Internet that sorts all values in a range alphabetically. It's this one:

Excel Formula:
=IFERROR(INDEX($C$4:$C$1000,MATCH(SMALL(NOT($C$4:$C$1000="")*IF(ISNUMBER($C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000)+SUM(--ISNUMBER($C$4:$C$1000))),ROWS($A$2:A2)+SUM(--ISBLANK($C$4:$C$1000))),NOT($C$4:$C$1000="")*IF(ISNUMBER($C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000)+SUM(--ISNUMBER($C$4:$C$1000))),0)),"")

I also have a formula that removes specific prepositions and articles (in Spanish) if F4 contains the value "Delete". It's this one:

Excel Formula:
=IF($F$4="Delete",IFERROR(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C21," de los "," ")," de las "," ")," de la "," ")," del "," ")," de "," ")," el "," ")," la "," ")," los "," ")," las "," ")," y "," ")," i "," ")," dels "," ")," de les "," ")," les "," ")," els "," ")," De Los "," ")," De Las "," ")," De La "," ")," Del "," ")," De "," ")," El "," ")," La "," ")," Los "," ")," Las "," ")," Y "," ")," I "," ")," Dels "," ")," De Les "," ")," Les "," ")," Els "," "),C21),C21)

My question is: is there a way to combine these two? I'd like to create a formula that sorts cells in a range with the ability to remove prepositions and articles during the sorting process. I tried with a LET function, but I can't figure out the way to blend them together. Here is a sample of what the sorted list looks like:

Avaluació 2022-23 PROVES.xlsx
CDEF
4Jorge Guzmán PedrazaAura López AlcázarDelete
5David Tejero GarcíaCarlos de la Torre Ramírez
6Tamara Bas MorenoDavid Tejero García
7Miguel de Ureña PérezFátima Andrade Bayarri
8Mónica Estadellas VacaFrancesco Schettino
9Lena García AlegreGabriela López-Moreno del Pino
10Francesco SchettinoJavier Alarcón Aznar
11Marta Arenas CabrerizoJavier Fernández Parra
12Aura López AlcázarJorge Guzmán Pedraza
13Javier Alarcón AznarJuan Antonio García García
14Kamohelo HrairaKamohelo Hraira
15Javier Fernández ParraLena García Alegre
16Fátima Andrade BayarriMaría de los Ángeles Ojeda de Morata
17Noemi Caravantes FenollosaMarta Arenas Cabrerizo
18Gabriela López-Moreno del PinoMiguel de Ureña Pérez
19Carlos de la Torre RamírezMiguel Ureña Yubero
20Juan Antonio García GarcíaMónica Estadellas Vaca
21María de los Ángeles Ojeda de MorataNoemi Caravantes Fenollosa
22Miguel Ureña YuberoTamara Bas Moreno
23 
24 
25 
Ordenadora
Cell Formulas
RangeFormula
D4:D25D4=IFERROR(INDEX($C$4:$C$1000,MATCH(SMALL(NOT($C$4:$C$1000="")*IF(ISNUMBER($C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000)+SUM(--ISNUMBER($C$4:$C$1000))),ROWS($A$2:A2)+SUM(--ISBLANK($C$4:$C$1000))),NOT($C$4:$C$1000="")*IF(ISNUMBER($C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000),COUNTIF($C$4:$C$1000,"<="&$C$4:$C$1000)+SUM(--ISNUMBER($C$4:$C$1000))),0)),"")


Thanks very much, guys!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try this

RonOliver.xlsm
CDEF
4Jorge Guzmán PedrazaAura López AlcázarDelete
5David Tejero GarcíaCarlos Torre Ramírez
6Tamara Bas MorenoDavid Tejero García
7Miguel de Ureña PérezFátima Andrade Bayarri
8Mónica Estadellas VacaFrancesco Schettino
9Lena García AlegreGabriela López-Moreno Pino
10Francesco SchettinoJavier Alarcón Aznar
11Marta Arenas CabrerizoJavier Fernández Parra
12Aura López AlcázarJorge Guzmán Pedraza
13Javier Alarcón AznarJuan Antonio García García
14Kamohelo HrairaKamohelo Hraira
15Javier Fernández ParraLena García Alegre
16Fátima Andrade BayarriMaría Ángeles Ojeda Morata
17Noemi Caravantes FenollosaMarta Arenas Cabrerizo
18Gabriela López-Moreno del PinoMiguel Ureña Pérez
19Carlos de la Torre RamírezMiguel Ureña Yubero
20Juan Antonio García GarcíaMónica Estadellas Vaca
21María de los Ángeles Ojeda de MorataNoemi Caravantes Fenollosa
22Miguel Ureña YuberoTamara Bas Moreno
Sheet1
Cell Formulas
RangeFormula
D4:D22D4=SORT(IF($F$4="Delete",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C4:C22," de los "," ")," de las "," ")," de la "," ")," del "," ")," de "," ")," el "," ")," la "," ")," los "," ")," las "," ")," y "," ")," i "," ")," dels "," ")," de les "," ")," les "," ")," els "," ")," De Los "," ")," De Las "," ")," De La "," ")," Del "," ")," De "," ")," El "," ")," La "," ")," Los "," ")," Las "," ")," Y "," ")," I "," ")," Dels "," ")," De Les "," ")," Les "," ")," Els "," "),C4:C22))
Dynamic array formulas.
 
Upvote 0
Try this

RonOliver.xlsm
CDEF
4Jorge Guzmán PedrazaAura López AlcázarDelete
5David Tejero GarcíaCarlos Torre Ramírez
6Tamara Bas MorenoDavid Tejero García
7Miguel de Ureña PérezFátima Andrade Bayarri
8Mónica Estadellas VacaFrancesco Schettino
9Lena García AlegreGabriela López-Moreno Pino
10Francesco SchettinoJavier Alarcón Aznar
11Marta Arenas CabrerizoJavier Fernández Parra
12Aura López AlcázarJorge Guzmán Pedraza
13Javier Alarcón AznarJuan Antonio García García
14Kamohelo HrairaKamohelo Hraira
15Javier Fernández ParraLena García Alegre
16Fátima Andrade BayarriMaría Ángeles Ojeda Morata
17Noemi Caravantes FenollosaMarta Arenas Cabrerizo
18Gabriela López-Moreno del PinoMiguel Ureña Pérez
19Carlos de la Torre RamírezMiguel Ureña Yubero
20Juan Antonio García GarcíaMónica Estadellas Vaca
21María de los Ángeles Ojeda de MorataNoemi Caravantes Fenollosa
22Miguel Ureña YuberoTamara Bas Moreno
Sheet1
Cell Formulas
RangeFormula
D4:D22D4=SORT(IF($F$4="Delete",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C4:C22," de los "," ")," de las "," ")," de la "," ")," del "," ")," de "," ")," el "," ")," la "," ")," los "," ")," las "," ")," y "," ")," i "," ")," dels "," ")," de les "," ")," les "," ")," els "," ")," De Los "," ")," De Las "," ")," De La "," ")," Del "," ")," De "," ")," El "," ")," La "," ")," Los "," ")," Las "," ")," Y "," ")," I "," ")," Dels "," ")," De Les "," ")," Les "," ")," Els "," "),C4:C22))
Dynamic array formulas.

That's actually really good, but the problem is it moves all the blank cells to the top, and I want them to be at the bottom in case there are any blank cells (which they're going to be), so cells with text come up first.
 
Upvote 0
Your list didn't appear to contain any blank cells and they were not mentioned in your question. ;)

RonOliver.xlsm
CDEF
4Jorge Guzmán PedrazaAura López AlcázarDelete
5David Tejero GarcíaCarlos Torre Ramírez
6Tamara Bas MorenoDavid Tejero García
7Miguel de Ureña PérezFátima Andrade Bayarri
8Mónica Estadellas VacaFrancesco Schettino
9Lena García AlegreGabriela López-Moreno Pino
10Francesco SchettinoJavier Alarcón Aznar
11Marta Arenas CabrerizoJavier Fernández Parra
12Aura López AlcázarJorge Guzmán Pedraza
13Javier Alarcón AznarJuan Antonio García García
14Kamohelo Hraira
15Kamohelo HrairaLena García Alegre
16Javier Fernández ParraMaría Ángeles Ojeda Morata
17Marta Arenas Cabrerizo
18Miguel Ureña Pérez
19Fátima Andrade BayarriMiguel Ureña Yubero
20Noemi Caravantes FenollosaMónica Estadellas Vaca
21Gabriela López-Moreno del PinoNoemi Caravantes Fenollosa
22Carlos de la Torre RamírezTamara Bas Moreno
23Juan Antonio García García
24María de los Ángeles Ojeda de Morata
25Miguel Ureña Yubero
Sheet1
Cell Formulas
RangeFormula
D4:D22D4=LET(f,SORT(IF($F$4="Delete",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C4:C25," de los "," ")," de las "," ")," de la "," ")," del "," ")," de "," ")," el "," ")," la "," ")," los "," ")," las "," ")," y "," ")," i "," ")," dels "," ")," de les "," ")," les "," ")," els "," ")," De Los "," ")," De Las "," ")," De La "," ")," Del "," ")," De "," ")," El "," ")," La "," ")," Los "," ")," Las "," ")," Y "," ")," I "," ")," Dels "," ")," De Les "," ")," Les "," ")," Els "," "),C4:C25)),FILTER(f,f<>""))
Dynamic array formulas.
 
Upvote 0
Your list didn't appear to contain any blank cells and they were not mentioned in your question.
Sorry, I can see now that your range went down to row 1000 so blanks definitely were involved. :)
Revised formula would be:

Excel Formula:
=LET(f,SORT(IF($F$4="Delete",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C4:C1000," de los "," ")," de las "," ")," de la "," ")," del "," ")," de "," ")," el "," ")," la "," ")," los "," ")," las "," ")," y "," ")," i "," ")," dels "," ")," de les "," ")," les "," ")," els "," ")," De Los "," ")," De Las "," ")," De La "," ")," Del "," ")," De "," ")," El "," ")," La "," ")," Los "," ")," Las "," ")," Y "," ")," I "," ")," Dels "," ")," De Les "," ")," Les "," ")," Els "," "),C4:C1000)),FILTER(f,f<>""))
 
Upvote 0
Solution
Sorry, I can see now that your range went down to row 1000 so blanks definitely were involved. :)
Revised formula would be:

Excel Formula:
=LET(f,SORT(IF($F$4="Delete",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C4:C1000," de los "," ")," de las "," ")," de la "," ")," del "," ")," de "," ")," el "," ")," la "," ")," los "," ")," las "," ")," y "," ")," i "," ")," dels "," ")," de les "," ")," les "," ")," els "," ")," De Los "," ")," De Las "," ")," De La "," ")," Del "," ")," De "," ")," El "," ")," La "," ")," Los "," ")," Las "," ")," Y "," ")," I "," ")," Dels "," ")," De Les "," ")," Les "," ")," Els "," "),C4:C1000)),FILTER(f,f<>""))
Yes, I added some extra cells at the bottom of my mini-sheet as a hint, but looking back I don't think it was enough. Thank you so much!!
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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