Excel : Need to add two digits to every line in a column
Moderator: Dictators in Training
- liquidstayce
- NT Veteran

- Posts: 1689
- Joined: Mon Mar 15, 2004 11:17 am
- Location: B-More
- Contact:
Excel : Need to add two digits to every line in a column
I have a file for work that has a column with patient medical record numbers. They look like this "M123456"
I need to just add two random digits to that number for the medical record number for every row. (aka - ghetto encryption)
Oh excel gurus.. How do I do this automatically? Manually entering the two extra numbers is out of the question!
Thanks!
I need to just add two random digits to that number for the medical record number for every row. (aka - ghetto encryption)
Oh excel gurus.. How do I do this automatically? Manually entering the two extra numbers is out of the question!
Thanks!
~stacy
- liquidstayce
- NT Veteran

- Posts: 1689
- Joined: Mon Mar 15, 2004 11:17 am
- Location: B-More
- Contact:
- liquidstayce
- NT Veteran

- Posts: 1689
- Joined: Mon Mar 15, 2004 11:17 am
- Location: B-More
- Contact:
Tikker wrote:hrm
It'd be much easier to pull it out of excel, use perl or awk against it, then import it back into excel
otherwise,
create another column somewhere with the random letter sequence you want (not sure the best way to do that) then just concatenate the 2 cells together
well forget perl or awk.. excel is all I have so your third idea would probably work but what do I use to make the random two digits in the new column? Then do I just merge the cells? How do I concatenate in excel... I can do string manipulation and all sorts of fun stuff in my proprietary healthcare IS programming language but I'm clueless in excel.
~stacy
- liquidstayce
- NT Veteran

- Posts: 1689
- Joined: Mon Mar 15, 2004 11:17 am
- Location: B-More
- Contact:
You can try this.
Lets say the value that you want to add 2 random digits to is in A1
=A1&DEC2HEX(RANDBETWEEN(0,256),2)
If you but that in B1. Then B1 will = A1 with 2 random hex digits at the end. Keep in mind those 4 digits would change every time you updated any field in the spreadsheet, thats just how rand woks.
Lets say the value that you want to add 2 random digits to is in A1
=A1&DEC2HEX(RANDBETWEEN(0,256),2)
If you but that in B1. Then B1 will = A1 with 2 random hex digits at the end. Keep in mind those 4 digits would change every time you updated any field in the spreadsheet, thats just how rand woks.
Last edited by Gidan on Mon Jun 20, 2005 5:24 pm, edited 1 time in total.
For to win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
- liquidstayce
- NT Veteran

- Posts: 1689
- Joined: Mon Mar 15, 2004 11:17 am
- Location: B-More
- Contact:
you get 2500 because only half your solution worked. I couldn't get the concatenate to work.
Gid - I couldn't get yours to work either but its probably just me doing something wrong. My numbers are set up in Column A - each a different cell. Adjust the formula for that and test it to see if it works and you can have the rest of my goat points =)
M123455
M234233
M984321
Gid - I couldn't get yours to work either but its probably just me doing something wrong. My numbers are set up in Column A - each a different cell. Adjust the formula for that and test it to see if it works and you can have the rest of my goat points =)
M123455
M234233
M984321
~stacy
Ok Excel should look something like this
(A1) M123455 (B1) =A1&DEC2HEX(RANDBETWEEN(0,256),2)
(A2) M234233 (B2) =A2&DEC2HEX(RANDBETWEEN(0,256),2)
(A3) M984321 (B3) =A3&DEC2HEX(RANDBETWEEN(0,256),2)
Make sure you have the analys pack addon installed or the dec2hex function may not work.
if it still doesn't work, what version of excel are you useing?
(A1) M123455 (B1) =A1&DEC2HEX(RANDBETWEEN(0,256),2)
(A2) M234233 (B2) =A2&DEC2HEX(RANDBETWEEN(0,256),2)
(A3) M984321 (B3) =A3&DEC2HEX(RANDBETWEEN(0,256),2)
Make sure you have the analys pack addon installed or the dec2hex function may not work.
if it still doesn't work, what version of excel are you useing?
For to win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
liquidstayce wrote:you get 2500 because only half your solution worked. I couldn't get the concatenate to work.
Gid - I couldn't get yours to work either but its probably just me doing something wrong. My numbers are set up in Column A - each a different cell. Adjust the formula for that and test it to see if it works and you can have the rest of my goat points =)
M123455
M234233
M984321
wtf, no gyping me just cause you suck at excel!
try this
in cell A1 type "m123" (no quotes obviously)
in cell b1 type "456"
then in c1 type "=concatenate(a1,b1)"
- liquidstayce
- NT Veteran

- Posts: 1689
- Joined: Mon Mar 15, 2004 11:17 am
- Location: B-More
- Contact:


