I would like to know if there is some way within MS Office that you can not
only calculate, but also display every letter combination within words or
chosen letters?
See: <
http://j-walk.com/ss/excel/tips/tip46.htm>.
Below is some VBA code derived from that. Note that the word Anagram will
yield 5040 permutations (7!).
Sub tGetPermutation()
Dim theWord As String
theWord = "Anagram"
Debug.Print "There are " & Factorial(Len(theWord)) & " permutations."
Call GetPermutation("", theWord)
End Sub
Function Factorial(n As Long) As Double
Dim y As Long
Factorial = n
For y = 2 To n - 1
Factorial = Factorial * y
Next y
End Function
Sub GetPermutation(x As String, y As String)
' from : <
http://j-walk.com/ss/excel/tips/tip46.htm>
' The source of this algorithm is unknown
Dim i As Integer, j As Integer
j = Len(y)
If j < 2 Then
Debug.Print x & y
Else
For i = 1 To j
Call GetPermutation(x + Mid(y, i, 1), Left(y, i - 1) + Right(y, j - i))
Next i
End If
End Sub