You can do it easily without VBA. First add a formula to an unused column:
---A---- --B--- ------------------C-------------------
1 Industry Unused
2 Banking 1 B2 and down: =IF(A2=A1, B1, SUM(B1,1))
3 Banking 1
4 Banking 1
5 Banking 1
6 Oil 2
7 Oil 2
8 Energy 3
9 Energy 3
10 Energy 3
The below that, list the numbers 1 to N twice:
--A--- B ---------C---------
9 Energy 3
10 Energy 3
11 1 B11 and down: Input
12 2
13 3
14 1
15 2
16 3
The copy col B over itself as values, and sort everything by col B:
---A---- --B---
1 Industry Unused
2 Banking 1
3 Banking 1
4 Banking 1
5 Banking 1
6 1
7 1
8 Oil 2
9 Oil 2
10 2
11 2
12 Energy 3
13 Energy 3
14 Energy 3
15 3
16 3
Then delete the uneeded column.
It takes way more time to explain than do.
Bookmarks