I have a text column with repeated values, for example:
| A |
---|---------|
1 | emails |
2 | foo |
3 | foo |
4 | bar |
5 | bar |
6 | stuff |
7 | stuff |
8 | stuff |
What I would like to do is to have another column with numbers, so that each number matches the value in the first column, for example:
| A | B |
---|---------|---------|
1 | emails | number |
2 | foo | 1 |
3 | foo | 1 |
4 | bar | 2 |
5 | bar | 2 |
6 | stuff | 3 |
7 | stuff | 3 |
8 | stuff | 3 |
If I understand your question correctly, the data maybe sorted and needs to be numbered by the distinct values in column A, so "foo" is 1 and "bar" is 2, and so on for unique values in column A.
I would use VBA and a Dictionary to build the list:
This will update the number in column B. You could also do things like putting the cell reference (such as "A2" or "A5") in column B which you could use for other Excel functions.
In order to use Scripting.Dictionary, just add a reference in Tools\References and select Microsoft Scripting Runtime.