List all possible combinations

united34

New Member
Joined
Oct 3, 2014
Messages
6
Hey guys,

I am having a difficult time with the following issue:

I am trying to list all the possible combinations of 4 between letters and numbers.
For example: 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1211, 1222...
AAAA, AAAB...AAAZ.
AAA1, AAA2, AAA3...AAA9.

Any suggestions?
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678
Are you trying to do this with excel formulas? Macro?


Code:
Sub allCombos()

Application.ScreenUpdating = False


Dim bank(35) As Variant
nextVal = 1


For x = 1 To 9
    bank(nextVal) = x
    nextVal = nextVal + 1
Next x


For x = 65 To 90
    bank(nextVal) = ChrW(x)
    nextVal = nextVal + 1
Next x


nextRow = 1


For x = 1 To 35
    For y = 1 To 35
        For Z = 1 To 35
            For a = 1 To 35
            
                Cells(nextRow, 1) = bank(x) & bank(y) & bank(Z) & bank(a)
                nextRow = nextRow + 1
                
            Next a
        Next Z
    Next y
Next x


Application.ScreenUpdating = True


End Sub


Here's a macro. It won't be a quick running one.
 
Last edited:

united34

New Member
Joined
Oct 3, 2014
Messages
6
I am trying to do this with Excel formulas, but am having a really tough time figuring it out. I am not familiar with macro, but I have been researching it and trying that also. So far what I've done is set up one column with 4 numbers, i.e., 1111, 1112...1119, and one column with letters, i.e., AAAA, AAAB...AAAZ. Then I did the concatenate function, but that results in 8 characters and I need 4 characters.

Any suggestion helps! Thank you :)
 

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678
I am trying to do this with Excel formulas, but am having a really tough time figuring it out. I am not familiar with macro, but I have been researching it and trying that also. So far what I've done is set up one column with 4 numbers, i.e., 1111, 1112...1119, and one column with letters, i.e., AAAA, AAAB...AAAZ. Then I did the concatenate function, but that results in 8 characters and I need 4 characters.

Any suggestion helps! Thank you :)


See my post #2. You do realize this will yield hundreds of thousands of rows, right? 1111, 1112, 1113, 1114, all the way to ZZZZ. I'm running it right now to see how many rows and how long it will take. I know there's a math way to figure it out but I can't figure it out.
 

united34

New Member
Joined
Oct 3, 2014
Messages
6

ADVERTISEMENT

Yeah, I am trying to get all the possible combinations and list them. I'm entering the macro right now
 

united34

New Member
Joined
Oct 3, 2014
Messages
6
Thank you so much for your help! I truly appreciate it. Have a great day!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,228
Messages
5,594,934
Members
413,953
Latest member
Arthur1471

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