help: 4-number permutations

N

Ng Tian Khean

Can somebody please help me? For a given 4-digit number, I would like to
create a column listing all the possible permutations of it. For example, if
the number is '1102' I would like a column showing 1102, 1012, 1021
..........N. (The formula/function Permut only tells ne how many permutations
of it, not list all the numbers. Please tell me clearly step by step how to
do it. It is for a class project.
Thank you.
 
M

Max

Here's 2 links to try:

a. Link posted by Biff previously which leads
to Myrna's post and power routine: http://tinyurl.com/6okbp

b. Try Jim Cone's add-in "Display Word Combinations"
which can handle alpha and numerics
It is available (for free) upon direct request to Jim ..
For details, see Jim's post at: http://tinyurl.com/6wz3c
 
H

Herbert Seidenberg

Here is a VBA solution. The spreadsheet solution is harder.
Sub perm4()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim m As Integer
Dim p As Integer
Dim NN As Integer
Range("A:A").ClearContents
NN = 4 - 1
p = 1
For i = 0 To NN
For j = 0 To NN
For k = 0 To NN
For m = 0 To NN
If Not (i = j Or i = k Or i = m Or j = k Or j = m _
Or k = m) Then
Range("A:A").Cells(p, 1) = i * 1000 + j * 100 + _
k * 10 + m
p = p + 1
End If
Next m
Next k
Next j
Next i
End Sub

Format column A > Custom > 0000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top