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)

[TABLE="width: 200, align: left"]
<tbody>[TR]
[TD][TABLE="width: 100"]
<tbody>[TR]
[TD]Existing Codes[/TD]
[/TR]
[TR]
[TD]A001[/TD]
[/TR]
[TR]
[TD]A002[/TD]
[/TR]
[TR]
[TD]A003[/TD]
[/TR]
[TR]
[TD]B001[/TD]
[/TR]
[TR]
[TD]B002[/TD]
[/TR]
[TR]
[TD]B003[/TD]
[/TR]
[TR]
[TD]B004[/TD]
[/TR]
[TR]
[TD]C001[/TD]
[/TR]
[TR]
[TD]D002[/TD]
[/TR]
[TR]
[TD]A004[/TD]
[/TR]
[TR]
[TD]A005[/TD]
[/TR]
[TR]
[TD]A006[/TD]
[/TR]
[TR]
[TD]A007[/TD]
[/TR]
[TR]
[TD]A008[/TD]
[/TR]
[TR]
[TD]A009[/TD]
[/TR]
[TR]
[TD]A010[/TD]
[/TR]
[TR]
[TD]A011[/TD]
[/TR]
[TR]
[TD]A024[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Thank You,[/TD]
[/TR]
[TR]
[TD]Deep[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,223,099
Messages
6,170,114
Members
452,302
Latest member
TaMere

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