sequencing letters

mattyb

New Member
Joined
Feb 13, 2008
Messages
17
I need to create a sequence of letters to be used in an alpha based identification code. I want the user to key in one code (ie PREAAAA ) where the frist four characters are constant and the last three build in sequential order. Example would be
1-PREAAAA
2-PREAAAB
3-PREAAAC
.....
n-PREAABA
.....
n-PREAACA
.....
Any thoughts on a formula that can do this?
Mattyb
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I have this, but it does not work for anything ending in Z after the first one and unfortunately I do not have the time at the moment to look in depth into this:

=IF(LEN(SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1",""))=1,"PREAAA"&SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1",""),IF(LEN(SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1",""))=2,"PREAA"&SUBSTITUTE(ADDRESS(1,INT(ROW(A1)/26),4),"1","")&SUBSTITUTE(ADDRESS(1,MOD(ROW(A1),26),4),"1",""),"PREA"&SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1","")))

Hope that helps.
 
Upvote 0
try putting this into a cell
="PREAA"&char(row(a65))

then when you copy down it will sequence from A to Z
 
Upvote 0
Actually I looked at it a little more and noticed a flaw with one thing and fixed that but still have the problem with it ending in Z because of how mod behaves, but could probably insert an if statement to fix that:

=IF(LEN(SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1",""))=1,"PREAAA"&SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1",""),IF(LEN(SUBSTITUTE(ADDRESS(1,ROW(A1),4),"1",""))=2,"PREAA"&SUBSTITUTE(ADDRESS(1,INT(ROW(A1)/26),4),"1","")&SUBSTITUTE(ADDRESS(1,MOD(ROW(A1),26),4),"1",""),"PREA"&SUBSTITUTE(ADDRESS(1,INT(ROW(A1)/676)+1,4),"1","")&SUBSTITUTE(ADDRESS(1,MOD(ROW(A1),676),4),"1","")))
 
Upvote 0
Hi

Another option. In A2:

="PREA"&CHAR(CODE("A")+INT((ROWS($A$2:A2)-1)/676))&CHAR(CODE("A")+MOD(INT((ROWS($A$2:A2)-1)/26),26))&CHAR(CODE("A")+MOD(ROWS($A$2:A2)-1,26))

Copy down
 
Upvote 0
if you're willing to entertain hex numbers:

=LEFT("000",LEN("000")-LEN(TEXT(DEC2HEX(ROW()),"000")))&(TEXT(DEC2HEX(ROW()),"000"))
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,541
Latest member
iparraguirre89

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