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?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
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:
Upvote 0
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 :)
 
Upvote 0
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.
 
Upvote 0
Yeah, I am trying to get all the possible combinations and list them. I'm entering the macro right now
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,034
Members
448,543
Latest member
MartinLarkin

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