Building a self-sorting list (Part 2)
In Part 1 we ended up with Column D, a sorted list. One criticism was the many times we were counting the numbers in a column. We should improve it and only count once. Via Insert/Name/Define define Count_BB to =COUNT(Sheet1!$B:$B), and then select Columns C:D, and “Replace All” COUNT(B:B) with Count_BB. Column D should look something like this:
| D | E | |
|---|---|---|
| 1 | Aart Moonhammer | =D1 |
| 2 | Aart Moonhammer | =IF(D2<>D1,D2,”") |
| 3 | Aart the Millwright | |
| 4 | Aart Whiteson | |
| 5 | Aberri of the White Heart | |
| 6 | Aberri the Thieving Wizard | |
| 7 | Acennan Badgerrunner | |
| 8 | Acennan Kenricsson | |
| 9 | Adei of the Red Ruins | |
| 10 | Adolphus Blackbird | |
| 11 | Adolphus Blackbird | |
| 12 | Adolphus Stillearth | |
| 13 | Adrik Yakovovich | |
| 14 | Aethelred Awierganson | |
| 15 | Aethelred Darkseed | |
| 16 | Ageio the Fastidious Sorceror |
In Cell E1 we simply move D1 over. In E2 we check to see if D2 is not equal to the cell above it, or in other words D2 starts a new run of names. If it is equal (FALSE condition) we put empty text. Otherwise, we put D2. Fill down from E2 as far down as columns B, C, and D are filled. Column E now looks like this. We have removed the duplicates.
| D | E | F | |
|---|---|---|---|
| 1 | Aart Moonhammer | Aart Moonhammer | =IF(LEN(E1)>0,ROW(),”") |
| 2 | Aart Moonhammer | ||
| 3 | Aart the Millwright | Aart the Millwright | |
| 4 | Aart Whiteson | Aart Whiteson | |
| 5 | Aberri of the White Heart | Aberri of the White Heart | |
| 6 | Aberri the Thieving Wizard | Aberri the Thieving Wizard | |
| 7 | Acennan Badgerrunner | Acennan Badgerrunner | |
| 8 | Acennan Kenricsson | Acennan Kenricsson | |
| 9 | Adei of the Red Ruins | Adei of the Red Ruins | |
| 10 | Adolphus Blackbird | Adolphus Blackbird | |
| 11 | Adolphus Blackbird | ||
| 12 | Adolphus Stillearth | Adolphus Stillearth | |
| 13 | Adrik Yakovovich | Adrik Yakovovich | |
| 14 | Aethelred Awierganson | Aethelred Awierganson | |
| 15 | Aethelred Darkseed | Aethelred Darkseed | |
| 16 | Ageio the Fastidious Sorceror | Ageio the Fastidious Sorceror |
In F1 we check to see if there is anything of length in E1. If there is, put the row number, otherwise put empty text. As above, define Count_FF as =COUNT(Sheet1!$F$F). After filling down, Column F looks like this:
| D | E | F | G | |
|---|---|---|---|---|
| 1 | Aart Moonhammer | Aart Moonhammer | 1 | =IF(ROW()<=Count_FF,SMALL(F:F,ROW()),”") |
| 2 | Aart Moonhammer | |||
| 3 | Aart the Millwright | Aart the Millwright | 3 | |
| 4 | Aart Whiteson | Aart Whiteson | 4 | |
| 5 | Aberri of the White Heart | Aberri of the White Heart | 5 | |
| 6 | Aberri the Thieving Wizard | Aberri the Thieving Wizard | 6 | |
| 7 | Acennan Badgerrunner | Acennan Badgerrunner | 7 | |
| 8 | Acennan Kenricsson | Acennan Kenricsson | 8 | |
| 9 | Adei of the Red Ruins | Adei of the Red Ruins | 9 | |
| 10 | Adolphus Blackbird | Adolphus Blackbird | 10 | |
| 11 | Adolphus Blackbird | |||
| 12 | Adolphus Stillearth | Adolphus Stillearth | 12 | |
| 13 | Adrik Yakovovich | Adrik Yakovovich | 13 | |
| 14 | Aethelred Awierganson | Aethelred Awierganson | 14 | |
| 15 | Aethelred Darkseed | Aethelred Darkseed | 15 | |
| 16 | Ageio the Fastidious Sorceror | Ageio the Fastidious Sorceror | 16 |
In G1 we again test the row number, but this time it’s against the count of numbers in F:F. If the ROW() is less than or equal to Count_FF, put the numbers from F:F there is ROW() order. Fill down as before. Column G looks like this:
| D | E | F | G | H | |
|---|---|---|---|---|---|
| 1 | Aart Moonhammer | Aart Moonhammer | 1 | 1 | =IF(ROW()<=Count_FF,INDEX(E:E,G1,1),”") |
| 2 | Aart Moonhammer | 3 | |||
| 3 | Aart the Millwright | Aart the Millwright | 3 | 4 | |
| 4 | Aart Whiteson | Aart Whiteson | 4 | 5 | |
| 5 | Aberri of the White Heart | Aberri of the White Heart | 5 | 6 | |
| 6 | Aberri the Thieving Wizard | Aberri the Thieving Wizard | 6 | 7 | |
| 7 | Acennan Badgerrunner | Acennan Badgerrunner | 7 | 8 | |
| 8 | Acennan Kenricsson | Acennan Kenricsson | 8 | 9 | |
| 9 | Adei of the Red Ruins | Adei of the Red Ruins | 9 | 10 | |
| 10 | Adolphus Blackbird | Adolphus Blackbird | 10 | 12 | |
| 11 | Adolphus Blackbird | 13 | |||
| 12 | Adolphus Stillearth | Adolphus Stillearth | 12 | 14 | |
| 13 | Adrik Yakovovich | Adrik Yakovovich | 13 | 15 | |
| 14 | Aethelred Awierganson | Aethelred Awierganson | 14 | 16 | |
| 15 | Aethelred Darkseed | Aethelred Darkseed | 15 | 18 | |
| 16 | Ageio the Fastidious Sorceror | Ageio the Fastidious Sorceror | 16 | 19 |
Last Step. In H1 we again compare the row number to the count of numbers in F:F. If ROW() is less than or equal to the Count_FF, then index E:E (could also be D:D) the number of rows shown in G:G. Fill down as before. Column H looks like this:
| D | E | F | G | H | |
|---|---|---|---|---|---|
| 1 | Aart Moonhammer | Aart Moonhammer | 1 | 1 | Aart Moonhammer |
| 2 | Aart Moonhammer | 3 | Aart the Millwright | ||
| 3 | Aart the Millwright | Aart the Millwright | 3 | 4 | Aart Whiteson |
| 4 | Aart Whiteson | Aart Whiteson | 4 | 5 | Aberri of the White Heart |
| 5 | Aberri of the White Heart | Aberri of the White Heart | 5 | 6 | Aberri the Thieving Wizard |
| 6 | Aberri the Thieving Wizard | Aberri the Thieving Wizard | 6 | 7 | Acennan Badgerrunner |
| 7 | Acennan Badgerrunner | Acennan Badgerrunner | 7 | 8 | Acennan Kenricsson |
| 8 | Acennan Kenricsson | Acennan Kenricsson | 8 | 9 | Adei of the Red Ruins |
| 9 | Adei of the Red Ruins | Adei of the Red Ruins | 9 | 10 | Adolphus Blackbird |
| 10 | Adolphus Blackbird | Adolphus Blackbird | 10 | 12 | Adolphus Stillearth |
| 11 | Adolphus Blackbird | 13 | Adrik Yakovovich | ||
| 12 | Adolphus Stillearth | Adolphus Stillearth | 12 | 14 | Aethelred Awierganson |
| 13 | Adrik Yakovovich | Adrik Yakovovich | 13 | 15 | Aethelred Darkseed |
| 14 | Aethelred Awierganson | Aethelred Awierganson | 14 | 16 | Ageio the Fastidious Sorceror |
| 15 | Aethelred Darkseed | Aethelred Darkseed | 15 | 18 | Agoztar of the Ghost Face |
| 16 | Ageio the Fastidious Sorceror | Ageio the Fastidious Sorceror | 16 | 19 | Aide of the Dead Woods |
The list that started in A:A is now sorted, de-duplicated, and collapsed to unique values, ready in H:H for whatever you might need as you write your fantasy novel. All you need to remember is to fill B2:Hn down well beyond any possible extent of A:A. This can be extended to handle several field records by indexing the appropriate columns at the two appropriate points.
…mrt
You can download self_sorting_names.zip

