+ Reply to Thread
Results 1 to 7 of 7

create a field in the macro to generate the 24 formations of the singles

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,179

    create a field in the macro to generate the 24 formations of the singles

    create a field in the macro to generate the 24 formations of the singles =
    ex = field digit
    2369 = 2639, 9362 ..... 24 formations, the macro will generate the 24 formations.
    * type in field 1359 = ... 24 forms

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,980

    Re: create a field in the macro to generate the 24 formations of the singles

    Sub TestMacro()
        Dim rngC As Range
        Dim i As Integer
        Dim j As Integer
        Dim k As Integer
        Dim m As Integer
        Dim str As String
        Dim lngR As Long
        
        lngR = 1
        
        str = InputBox("4 digits")
        
        For i = 1 To 4
            For j = 1 To 4
                For k = 1 To 4
                    For m = 1 To 4
                        If i <> j And j <> k And k <> m And i <> k And i <> m And j <> m Then
                            Cells(lngR, "A").Value = "'" & Mid(str, i, 1) & Mid(str, j, 1) & Mid(str, k, 1) & Mid(str, m, 1)
                            lngR = lngR + 1
                        End If
                    Next m
                Next k
            Next j
        Next i  
    End Sub
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    05-10-2016
    Location
    Cordoba, Argentina
    MS-Off Ver
    2016
    Posts
    27

    Re: create a field in the macro to generate the 24 formations of the singles

    Hi Jorel,
    Here is an idea in what I call it fuerza-bruta
    Function CalcularVariaciones(base As String) As String
    Dim B(3) As String
    Dim V(23) As String
    B(0) = Mid(base, 1, 1)
    B(1) = Mid(base, 2, 1)
    B(2) = Mid(base, 3, 1)
    B(3) = Mid(base, 4, 1)
    
    V(0) = B(0) & B(1) & B(2) & B(3)
    V(1) = B(0) & B(1) & B(3) & B(2)
    V(2) = B(0) & B(2) & B(1) & B(3)
    V(3) = B(0) & B(2) & B(3) & B(1)
    V(4) = B(0) & B(3) & B(1) & B(2)
    V(5) = B(0) & B(3) & B(2) & B(1)
    V(6) = B(1) & B(0) & B(2) & B(3)
    V(7) = B(1) & B(0) & B(3) & B(2)
    V(8) = B(1) & B(2) & B(0) & B(3)
    V(9) = B(1) & B(2) & B(3) & B(0)
    V(10) = B(1) & B(3) & B(0) & B(2)
    V(11) = B(1) & B(3) & B(2) & B(0)
    V(12) = B(2) & B(0) & B(1) & B(3)
    V(13) = B(2) & B(0) & B(3) & B(1)
    V(14) = B(2) & B(1) & B(0) & B(3)
    V(15) = B(2) & B(1) & B(3) & B(0)
    V(16) = B(2) & B(3) & B(0) & B(1)
    V(17) = B(2) & B(3) & B(1) & B(0)
    V(18) = B(3) & B(0) & B(1) & B(2)
    V(19) = B(3) & B(0) & B(2) & B(1)
    V(20) = B(3) & B(1) & B(0) & B(2)
    V(21) = B(3) & B(1) & B(2) & B(0)
    V(22) = B(3) & B(2) & B(0) & B(1)
    V(23) = B(3) & B(2) & B(1) & B(0)
    
    CalcularVariaciones = ""
    
    For i = 0 To 23
        CalcularVariaciones = CalcularVariaciones & V(i) & ", "
    Next i
    
    CalcularVariaciones = Left(CalcularVariaciones, Len(CalcularVariaciones) - 2)
    
    End Function
    Cheers
    Sergio

  4. #4
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,179

    Re: create a field in the macro to generate the 24 formations of the singles

    hello bernie, PERFECT, works well, corret, congratulations, thank you

  5. #5
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,179

    Re: create a field in the macro to generate the 24 formations of the singles

    hello SEGIO tu macro no crea el campo para escribir los 4 números,

  6. #6
    Registered User
    Join Date
    05-10-2016
    Location
    Cordoba, Argentina
    MS-Off Ver
    2016
    Posts
    27

    Re: create a field in the macro to generate the 24 formations of the singles

    Hi Jorel, is a function (UDF) you have to use it in a cell formula like you have 2369 in A2 in B2 you have to write
    B2 =CalcularVariaciones(A2)
    Cheers
    Sergio

  7. #7
    Forum Contributor
    Join Date
    11-29-2014
    Location
    brasil
    MS-Off Ver
    excel 2016
    Posts
    2,179

    Re: create a field in the macro to generate the 24 formations of the singles

    ok,SERGIO,thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. generate random formations, but in the following factions .
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2018, 07:27 AM
  2. hello please generate all the formations of each pattern.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2018, 10:18 AM
  3. hello please generate formations of 5 numbers in the criteria *.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2018, 11:15 AM
  4. Generate all the formations a number each letter.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2018, 06:10 PM
  5. Generate all possible formations using strings 0 to 3 whose sum is 14 .
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2018, 09:21 AM
  6. Request = generate positional pairs identifying by the 24 formations
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2017, 07:11 AM
  7. [SOLVED] Generate random formations, but without repeating the letters in the columns and in the ro
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 04-13-2017, 01:15 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1