How to give unique numbers to a set of repeated column values in MS- Excel

时间:2016-02-02 10:40:17

标签: excel excel-vba excel-formula vba

I have a column field called State and it contains 38 different states, which keeps repeating( total column count is 154000). I have sorted the column field. Now I want to add another column named State id, which should function in such a way that for each State there should be a unique State id

For example, if 1st state is repeating 5000 times and 2nd state is repeating 25000 times - the State Id value should have 1 repeating 5000 times for 1st state and 2 repeating 25000 times for 2nd State and the same logic should be applicable for other states as well

Is it possible using excel?

2 个答案:

答案 0 :(得分:0)

您可以在另一个标签页上设置查找表

州身份
德克萨斯州1 特拉华州2 肯塔基州3

然后在你的主列表中使用= vlookup公式来匹配状态名称并返回id。

答案 1 :(得分:0)

您还可以使用if来验证该状态是否已具有id,然后创建一个新ID。当然,这一切都在循环中。

相关问题