HI Stephen,
"Could it be because the name in the first column is either hyphenated, or even multiple words with spaces?"
Multiple words shouldn't cause problems, as seen in the example with "St john."
That should be true of names containing punctuation as well.
The first COUNTIF function used in column C of Table 1 COUNTIF(A$1:A2,A2, checks only whether the values in cells in its assigned range match or don't match the value in the cell containing the specific value in 'this row' of column A.
In C2, the count will always be 1, as the range of cells being counted is A1 to A2, Ai contains the label (surnames) of the column; A2 contains the surname that is the text being counted, and those are the only two cells that this copy of the formula counts.
The same fornula, in C10 COUNTIF(A$1:A10,A10) starts its count a A1 and ends it at A10, counting the times the name in A10 (which, in the example, is the same name as in A2, and in every cell between A2 and A10), and returns a count of 9.
In the next row, C11, The range counted expands by one more cell, and the name being counted is now the name in A11, "Lee".
This is the first occurrence of Lee in the column, so, as in C2, the count is 1.
As MATCH cannot distinguish between 1 in C2 and 1 in C11, we need to modify the count be a minuscule amount to provide distinct numbers for these two 'first occurrence occasions, taking care that the result is always less than 2.
That is taken care of with the +ROW()/10000 part of the formula, which adds the row number divided by ten thousand to each sum to make every value in column C distinct from every other value in that column (up to a total of 9999 names). If your table has more that 10000 rows, increase this divisor to the first power of 10 greater than the maximum number of (full) names in the table.
"I'm copying the text you have above into A2 and B2 of the table, and then filling down. Is this correct?
No.
Copied directly into a cell, these will be seen as 'text', not as formulas, and will be seen as the 'content' of each of the cells in the column.
A2 INDEX(Table 1::A,MATCH(SMALL(Table 1::C,ROW(cell)−1),Table 1::C,0))
A2 in this example tells which cell (of Table 2) the formula is to be placed in. The rest, shown in bold is the formula.
To place the two formulas:
- Select and copy the A2 formula from my post here.
- Click once on cell A2.
- type = to open the Formula Editor.
- Paste to place the formula in the editor.
- Click the green checkmark dot to confirm the formula and close the editor.
B2 COUNTIF(Table 1::A,A2)
- Repeat those steps using cell B2 and the formula for that cell.
Fill down:
- Select cells BA2 and B2
- Hover the mouse pointer near the bottom edge of the two selected cells.
- When the yellow dot appears, use the pointer and mouse button to grab it and drag dow, filling the formula into as many rows as needed.
Regards,
Barry
PS: Everyone here was a noob at one time. Don't let it get you down, and don't let it stop you from asking questions.
B.