Every Three Letter Combination

Nexx

New Member
Joined
Aug 27, 2009
Messages
29
Hi,

Could anyone help me with a macro or formula that could list every three letter combination from AAA to ZZZ in column A of a workbook? Just the logic would be fine as I'm starting to think that the way I've thought of doing it is over complicating it.

Thank you.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
One idea

Code:
Sub List_Combos()
Dim a As Integer, b As Integer, c As Integer
Dim lst As Long
'65 to 90
For a = 65 To 90
    For b = 65 To 90
        For c = 65 To 90
            lst = Sheet1.Range("A" & Rows.Count).End(xlUp).Row + 1
            Sheet1.Range("A" & lst).Value = Chr(a) & Chr(b) & Chr(c)
        Next c
    Next b
Next a


End Sub
 
Upvote 0
Try this.
Code:
Option Explicit
 
Sub Combos()
Dim I As Long, J As Long, K As Long
Dim s As String
Dim rng As Range
 
    Set rng = Range("A1")

    For I = 1 To 26
        For J = 1 To 26
            For K = 1 To 26
                s = Chr(Asc("A") + I - 1) & Chr(Asc("A") + J - 1) & Chr(Asc("A") + K - 1)
                rng.Value = s
                Set rng = rng.Offset(1)
            Next
        Next
    Next
    
End Sub
 
Upvote 0
Hi

A formula solution for the permutations in columns A:C

In A1:

=IF(ROWS(A$1:A1)>17576,"",CHAR(65+MOD((ROWS(A$1:A1)-1)/26^(3-COLUMNS($A1:A1)),26)))

Copy down and to the right.
 
Upvote 0
pgc beat me to it with the formula version but may as well post my single column effort

=IF(ROW(A1)<=(26^3),CHAR(65+INT((ROW(A1)-1)/26^2))&CHAR(65+MOD(INT((ROW(A1)-1)/26),26))&CHAR(65+MOD(ROW(A1)-1,26)),"")
 
Upvote 0
Cheers guys! Beats my solution of first putting A to Z in an array and then using the array in some loops.
 
Upvote 0

Forum statistics

Threads
1,225,341
Messages
6,184,372
Members
453,228
Latest member
badaflash

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