Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel 2007 - Generate unique ID based on text?

I have a sheet with a list of names in Column B and an ID column in A. I was wondering if there is some kind of formula that can take the value in column B of that row and generate some kind of ID based on the text? Each name is also unique and is never repeated in any way.

It would be best if I didn't have to use VBA really. But if I have to, so be it.

like image 649
Kenny Bones Avatar asked Nov 08 '11 07:11

Kenny Bones


People also ask

How do I convert a string to a unique number in Excel?

If your values were in column B, starting in B2 underneath your headers for example, in A2 you would type the formula "=IF(B2="","",1+MAX(A$1:A1))". You can copy and paste that down as far as your data extends, and it will increment a numeric identifier for each row in column B which isn't blank.

How do you create a unique identifier?

The simplest way to generate identifiers is by a serial number. A steadily increasing number that is assigned to whatever you need to identify next. This is the approached used in most internal databases as well as some commonly encountered public identifiers.


1 Answers

Solution Without VBA.

Logic based on First 8 characters + number of character in a cell.

= CODE(cell) which returns Code number for first letter

= CODE(MID(cell,2,1)) returns Code number for second letter

= IFERROR(CODE(MID(cell,9,1)) If 9th character does not exist then return 0

= LEN(cell) number of character in a cell

Concatenating firs 8 codes + adding length of character on the end

If 8 character is not enough, then replicate additional codes for next characters in a string.

Final function:

=CODE(B2)&IFERROR(CODE(MID(B2,2,1)),0)&IFERROR(CODE(MID(B2,3,1)),0)&IFERROR(CODE(MID(B2,4,1)),0)&IFERROR(CODE(MID(B2,5,1)),0)&IFERROR(CODE(MID(B2,6,1)),0)&IFERROR(CODE(MID(B2,7,1)),0)&IFERROR(CODE(MID(B2,8,1)),0)&LEN(B2)

enter image description here

like image 181
milan minarovic Avatar answered Sep 28 '22 09:09

milan minarovic