Create Unique Numeric String from Alphanumeric String

zzer0

New Member
Joined
Oct 23, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I need to create a unique 5 digit code that is generated from a 4 digit alphanumeric string. See below for an example.

4 Digit Alphanumeric Code5 Digit Code
ABBO
10001​
ABEL
10002​
ABER
10003​
ABRA
10004​
ADAD
10005​
ADAD
10005​
ADAD
10005​
ADAD
10005​
ADAM
10006​
ADAM
10006​
ADAM
10006​
ADLE
10007​
ADLE
10007​
ADST
10008​
ADST
10008​
AHRE
10009​
AHRE
10010​
AICF
10011​


The 5 digit code could be any number, as long as it is unique based on the 4 digit input. I thought about assigning numbers to letters but the numbers get too large i.e. ZZZZ would be 26262626. I have over a thousand unique 4 digit codes and I'd prefer not to have to go one by one assigning them 5 digit codes manually. Any guidance is greatly appreciated!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Why don't you just number them sequentially like you did in your example?
 
Upvote 0
Why don't you just number them sequentially like you did in your example?
Hi Scott,

I could for sure, but because I have over 2000 4 digit codes it would be tedious to do it manually when a formula might be able to do the trick. I'm not opposed to doing it manually but I figured I'd ask here first.
 
Upvote 0
It looks like you only want new codes for new numbers.
Really simple solution.

Sort your 4 Digit Alphanumeric Codes in alphabetical order.
Then, place "10001" on the first row (let's say cell B2).
Then in cell B3, enter this formula and copy down for all rows:
Excel Formula:
=IF(A3=A2,B2,B2+1)

Your results will look like this (formulas in red):

1704911810521.png
 
Upvote 0
Solution
I wasn't actually suggesting you do it manually, I was just asking why they couldn't go sequentially.
 
Upvote 0
It looks like you only want new codes for new numbers.
Really simple solution.

Sort your 4 Digit Alphanumeric Codes in alphabetical order.
Then, place "10001" on the first row (let's say cell B2).
Then in cell B3, enter this formula and copy down for all rows:
Excel Formula:
=IF(A3=A2,B2,B2+1)

Your results will look like this (formulas in red):

View attachment 104747
Thanks, Joe4!

Appreciate your help, this is a really simple solution, I'm ashamed I didn't think of it first. Appreciate your help.
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,093
Latest member
ripvw

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