Increase letter and number sequence in order

mc612

New Member
Joined
Jan 21, 2025
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I am creating a SKU system for a huge catalogue of items that will grow and grow over time, I'm looking to future proof with a SKU that can create over a billion variations so I will never run out and is easy to understand

I'm looking at the following:

AA0A0AA
AA0A0AB
AA0A0AC

up to:

ZZ9Z9ZX
ZZ9Z9ZY
ZZ9Z9ZZ

I understand I can only go to a little over 1 million at a time, therefore is there a formula to increment the start point by 1, so if I start with AA0A0AA it will increment to AA0A0AB, equally if I started randomly with say FV3D8TH would increment to FV3D8TI?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi @mc612 and welcome to MrExcel board!
I suggest you run a macro.

On a sheet, in cell A2 put the initial SKU, it can be AA0A0AA or FV3D8TH.

In cell B2 write the growth number you want, it can be 10, 1000 or a million (this could take a while to generate).

Example:
Dante Amor
AB
1SKUGROW
2FV3D8TH10
3
4
5
6
7
8
9
10
11
12
Hoja1


After run the macro:
Dante Amor
AB
1SKUGROW
2FV3D8TH10
3FV3D8TI
4FV3D8TJ
5FV3D8TK
6FV3D8TL
7FV3D8TM
8FV3D8TN
9FV3D8TO
10FV3D8TP
11FV3D8TQ
12FV3D8TR
Hoja1


Put the following macro in a module:
VBA Code:
Sub Increase_letter_and_number_v1()
  Dim StartCell As String, sku As String, itm As String
  Dim i As Long, nGrow As Long, n As Long, aItm As Long
  Dim cell As Range
  Dim a As Variant
  
  StartCell = "A2"
  nGrow = Range("B2")
  
  Set cell = Range(StartCell)
  Range(Cells(cell.Row + 1, cell.Column), Cells(Rows.Count, cell.Column)).ClearContents
  
  sku = cell.Value
  n = 7
  ReDim a(1 To nGrow, 1 To 1)
  
  For i = 1 To nGrow
    Do While True
      Select Case n
        Case 7                            'letter
          itm = Mid(sku, n, 1)
          aItm = Asc(itm) + 1
          If aItm = 91 Then
            n = 6
            sku = Left(sku, 6) & "A"
          Else
            n = 7
            sku = Left(sku, 6) & Chr(aItm)
            Exit Do
          End If
        Case 6                            'letter
          itm = Mid(sku, n, 1)
          aItm = Asc(itm) + 1
          If aItm = 91 Then
            n = 5
            sku = Left(sku, 5) & "A" & Right(sku, 1)
          Else
            sku = Left(sku, 5) & Chr(aItm) & Right(sku, 1)
            n = 7
            Exit Do
          End If
        Case 5                            'number
          itm = Mid(sku, n, 1)
          aItm = itm + 1
          If aItm = 10 Then
            n = 4
            sku = Left(sku, 4) & "0" & Right(sku, 2)
          Else
            sku = Left(sku, 4) & aItm & Right(sku, 2)
            n = 7
            Exit Do
          End If
        Case 4                            'letter
          itm = Mid(sku, n, 1)
          aItm = Asc(itm) + 1
          If aItm = 91 Then
            n = 3
            sku = Left(sku, 3) & "A" & Right(sku, 3)
          Else
            sku = Left(sku, 3) & Chr(aItm) & Right(sku, 3)
            n = 7
            Exit Do
          End If
        Case 3                            'number
          itm = Mid(sku, n, 1)
          aItm = itm + 1
          If aItm = 10 Then
            n = 2
            sku = Left(sku, 2) & "0" & Right(sku, 4)
          Else
            sku = Left(sku, 2) & aItm & Right(sku, 4)
            n = 7
            Exit Do
          End If
        Case 2                            'letter
          itm = Mid(sku, n, 1)
          aItm = Asc(itm) + 1
          If aItm = 91 Then
            n = 1
            sku = Left(sku, 1) & "A" & Right(sku, 5)
          Else
            sku = Left(sku, 1) & Chr(aItm) & Right(sku, 5)
            n = 7
            Exit Do
          End If
        Case 1                            'letter
          itm = Mid(sku, n, 1)
          aItm = Asc(itm) + 1
          If aItm = 91 Then
            n = 0
            Exit Do
          Else
            sku = Chr(aItm) & Right(sku, 6)
            n = 7
            Exit Do
          End If
      End Select
    Loop
    
    If n = 0 Then Exit For
    a(i, 1) = sku
  Next
  
  cell.Offset(1).Resize(UBound(a)).Value = a
End Sub


INSERT A MACRO
Press Alt-F11 to open the VBA editor. From the menu select Insert > Module. On the sheet that opens, paste the code previous.​
Close the editor (press Alt-Q). From Excel, press Alt-F8 to open the macro selector, and select Increase_letter_and_number_v1 and press Run.​
Make sure you save your file as an "Excel Macro-Enabled Workbook.​

🤗
 
Upvote 0
I understand I can only go to a little over 1 million at a time
...
AA0A0AA
...
ZZ9Z9ZZ
In fact from the first combination to the last combination, the number of total combinations is 1,188,137,600 That is, more than one thousand one hundred million (billion)

😅
 
Upvote 0
I'm looking to future proof with a SKU that can create over a billion variations so I will never run out

Like I said, future proofing! We sell preowned clothing with every item having a new, unique SKU, so need a system that will pretty much never run out
 
Upvote 0

Forum statistics

Threads
1,225,725
Messages
6,186,646
Members
453,367
Latest member
bookiiemonster

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