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
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
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
Hi Jorel,
Here is an idea in what I call it fuerza-bruta
CheersFunction 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
Sergio
hello bernie, PERFECT, works well, corret, congratulations, thank you
hello SEGIO tu macro no crea el campo para escribir los 4 números,
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
CheersB2 =CalcularVariaciones(A2)
Sergio
ok,SERGIO,thank you
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks