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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,941
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

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
try putting this into a cell
="PREAA"&char(row(a65))

then when you copy down it will sequence from A to Z
 
Upvote 0

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,941
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

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,892
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

nbrcrunch

Well-known Member
Joined
Jan 1, 2003
Messages
2,062
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,191,077
Messages
5,984,503
Members
439,894
Latest member
Amba1006

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
Top