Code for creating a Alphabetical sequence.

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
826
Office Version
  1. 365
Platform
  1. Windows
Our company uses Letter formats to track our material. I was wanting to be able to automate this process a little. We use 5 letters ( GTCBA ) and ever time we add more material it gets a new code which would be like GTCBB the list goe on and on. We keep up with this on Column A of an Excel spreadsheet but it is all manually entered. If you have any ideas or suggestions please share. Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
try this User Defined Function:

Code:
Function StrngPlus(Srce As String, Step As Integer)
    Dim ltrs As String
    Dim n As Integer
    Dim Carry As Integer
    
    For n = 1 To Len(Srce)
        If Asc(Right(Srce, n)) + Carry + Step > Asc("Z") Then
           ltrs = Chr(65 + ((Asc(Right(Srce, n)) + Carry + Step - 65) Mod 26)) & ltrs
           Carry = 1
        Else
           ltrs = Chr(65 + ((Asc(Right(Srce, n)) + Carry + Step - 65) Mod 26)) & ltrs
           Carry = 0
        End If
        Step = 0
    Next n
    
    If Carry = 1 Then ltrs = "A" & ltrs
    
    StrngPlus = ltrs
    
End Function

You'll need to enter it into a Module and then in the simply insert =StrngPlus(A1,1) into A2 and copy down (or something similar). If you want to increment the letters more than 1 at a time simply replace the 1 with whatever step you want.

Hope this helps.
 
Upvote 0
Our company uses Letter formats to track our material. I was wanting to be able to automate this process a little. We use 5 letters ( GTCBA ) and ever time we add more material it gets a new code which would be like GTCBB the list goe on and on. We keep up with this on Column A of an Excel spreadsheet but it is all manually entered. If you have any ideas or suggestions please share. Thanks
Thank you that works great
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,292
Members
449,498
Latest member
Lee_ray

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