Results 1 to 4 of 4

Thread: Help needed for creating permutation list

  1. #1
    Join Date
    Dec 2008
    Posts
    135

    Help needed for creating permutation list

    Hello friends,

    I am facing an issue while creating permutation list in Excel. I have several items that I would like to combine, lets call them characters l,m,n,o

    Each character is situated in a different column, next to each other.The sequence is not important for me,but each row should contain a unique combination of characters.

    Can anyone help me out with this issue.


    Intel Core 2 Duo 2.8 Ghz
    G31 Asrock Motherboard with Intel chipset
    1gb RAM
    GeForce 6200 TC
    500gb HDD

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Help needed for creating permutation list

    Try to use the following code:-

    Code:
    Sub Permute2atatime()
    Dim v, i, j, k
    v = Array("l", "m", "n", "o")
    k = 1
    For i = LBound(v) To UBound(v)
     For j = LBound(v) To UBound(v)
      If i <> j Then
       s = v(i) & " " & v(j)
       Cells(k, 2) = s
       k = k + 1
      End If
     Next
    Next
    
    
    End Sub

  3. #3
    Join Date
    Dec 2008
    Posts
    135

    Re: Help needed for creating permutation list

    I try to use the above code it is not working for me.


    Intel Core 2 Duo 2.8 Ghz
    G31 Asrock Motherboard with Intel chipset
    1gb RAM
    GeForce 6200 TC
    500gb HDD

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Help needed for creating permutation list

    Try to use the following code i am sure it will work for you.

    Code:
    Dim CurrentRow
    
    Sub GetString()
    Dim InString As String
    InString = InputBox("Enter text to permute:")
    If Len(InString) < 2 Then Exit Sub
    If Len(InString) >= 8 Then
    MsgBox "Too many permutations!"
    Exit Sub
    Else
    ActiveSheet.Columns(1).Clear
    CurrentRow = 1
    Call GetPermutation("", InString)
    End If
    End Sub
    
    Sub GetPermutation(x As String, y As String)
    Dim i As Integer, j As Integer
    j = Len(y)
    If j < 2 Then
    Cells(CurrentRow, 1) = x & y
    CurrentRow = CurrentRow + 1
    Else
    For i = 1 To j
    Call GetPermutation(x + Mid(y, i, 1), _
    Left(y, i - 1) + Right(y, j - i))
    Next
    End If
    End Sub

Similar Threads

  1. Windows phone 7: list of needed fixes.
    By DJ AM in forum Portable Devices
    Replies: 9
    Last Post: 24-09-2011, 04:04 PM
  2. Replies: 3
    Last Post: 23-08-2011, 01:06 AM
  3. List of applications needed in CloudMe
    By Boreanaz in forum Technology & Internet
    Replies: 5
    Last Post: 15-06-2011, 05:38 PM
  4. Replies: 4
    Last Post: 30-12-2010, 10:41 PM
  5. ddr3 ram supported intel motherboard price list needed
    By elex13 in forum Motherboard Processor & RAM
    Replies: 3
    Last Post: 22-06-2009, 11:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,526,450.50160 seconds with 17 queries