How to generate sequence based on cell values

himalarohee

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


Citry# of salesman
Richardson5
Irving3
Plano2

<tbody>
</tbody>

I need to generate unique IDs for the salesman and the table would look like:
Salesman Unique ID
Richardson-1
Richardson-2
Richardson-3
Richardson-4
Richardson-5
Irving-1
Irving-2
Irving-3
Plano-1
Plano-2

<tbody>
</tbody>

Your help is much appreciated.

Regards,
himalarohee
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

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,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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