How to generate sequence based on cell values

himalarohee

New Member
Joined
Mar 11, 2012
Messages
19
Hi, I have data like


[TABLE="width: 200"]
<tbody>[TR]
[TD]Citry[/TD]
[TD]# of salesman[/TD]
[/TR]
[TR]
[TD]Richardson[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]Irving[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Plano[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]

I need to generate unique IDs for the salesman and the table would look like:
[TABLE="width: 200"]
<tbody>[TR]
[TD]Salesman Unique ID[/TD]
[/TR]
[TR]
[TD]Richardson-1[/TD]
[/TR]
[TR]
[TD]Richardson-2[/TD]
[/TR]
[TR]
[TD]Richardson-3[/TD]
[/TR]
[TR]
[TD]Richardson-4[/TD]
[/TR]
[TR]
[TD]Richardson-5[/TD]
[/TR]
[TR]
[TD]Irving-1[/TD]
[/TR]
[TR]
[TD]Irving-2[/TD]
[/TR]
[TR]
[TD]Irving-3[/TD]
[/TR]
[TR]
[TD]Plano-1[/TD]
[/TR]
[TR]
[TD]Plano-2[/TD]
[/TR]
</tbody>[/TABLE]

Your help is much appreciated.

Regards,
himalarohee
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Excel 2010
AB
1City# of salesman
2Richardson5
3Irving3
4Plano2
5
6
7ID
8Richardson-1
9Richardson-2
10Richardson-3
11Richardson-4
12Richardson-5
13Irving-1
14Irving-2
15Irving-3
16Plano-1
17Plano-2
Sheet5 (7)
Cell Formulas
RangeFormula
A8=IF(ROW(A1)=1,$A$2&"-1",IF(VLOOKUP(LEFT(A7,FIND("-",A7,1)-1),$A$2:$B$4,2,0)=VALUE(MID(A7,FIND("-",A7,1)+1,100)),INDEX($A$1:$A$4,SUMPRODUCT(--($A$1:$A$4=LEFT(A7,FIND("-",A7,1)-1)),ROW($A$1:$A$4))+1)&"-1",LEFT(A7,FIND("-",A7,1)-1)&"-"&MID(A7,FIND("-",A7,1)+1,100)+1))






=IF(ROW(A1)=1,$A$2&"-1",IF(VLOOKUP(LEFT(A7,FIND("-",A7,1)-1),$A$2:$B$4,2,0)=VALUE(MID(A7,FIND("-",A7,1)+1,100)),INDEX($A$1:$A$4,SUMPRODUCT(--($A$1:$A$4=LEFT(A7,FIND("-",A7,1)-1)),ROW($A$1:$A$4))+1)&"-1",LEFT(A7,FIND("-",A7,1)-1)&"-"&MID(A7,FIND("-",A7,1)+1,100)+1))
 
Upvote 0
Thank you so much it worked like a charm.
I replaced the sumproduct with match statement. I believe the formula will be less CPU intensive when I am running on many cells. Right???
 
Upvote 0
Yes you're right. I usually go with match and almost did here, but thought sumproduct might be less to type (it's not).
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top