Next Customer Code

Deep Dave

Board Regular
Joined
Mar 22, 2013
Messages
77
I have a bunch of existing customer codes, in Range A1:A19. in Cell B2, I have a drop down with letters from A - Z. The user should select any letter from the Drop Down, and in cell C2, the next available Customer Code starting with that letter should be visible. In the below example, if the user selects B from the Drop Down, the output in cell C2 should be B005. Can anyone help me with this. (Request a Formula as an answer and not VBA)

Existing Codes
A001
A002
A003
B001
B002
B003
B004
C001
D002
A004
A005
A006
A007
A008
A009
A010
A011
A024

<tbody>
</tbody>
Thank You,
Deep

<tbody>
</tbody>
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Another way (array formula - use Ctrl+Shift+Enter and not only Enter):

Code:
=B2&TEXT(MAX(IFERROR(1+SUBSTITUTE(A2:A18,B2,""),1)),"000")

Markmzz
 
Upvote 0
Hi markmzz -

The Formula works correctly except when a letter is chosen that does not already have a Code assigned to it.. For example If I select "I" from the Drop Down, it returns I001, but it actually should return I000.

:) Great formula none the less..

Thnx
Deep
 
Upvote 0
Hi markmzz -

The Formula works correctly except when a letter is chosen that does not already have a Code assigned to it.. For example If I select "I" from the Drop Down, it returns I001, but it actually should return I000.

:) Great formula none the less..

Thnx
Deep

If you want I000 in this case, try this small modification (array formula - use Ctrl+Shift+Enter and not only Enter):

Code:
=B2&TEXT(MAX(IFERROR(1+SUBSTITUTE(A2:A18,B2,""),[COLOR="#FF0000"][B]0[/B][/COLOR])),"000")

Markmzz
 
Upvote 0

Forum statistics

Threads
1,215,978
Messages
6,128,063
Members
449,416
Latest member
SHIVANISHARMA1711

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