hello, generate all the formations of the 3 letters .

piter

Active Member
Joined
Jul 22, 2011
Messages
316
Office Version
  1. 2016
Platform
  1. Windows
hello, generate all the formations of the 3 letters
in the following criterion = no more than 5 letters for each of the 3 lines
a = 01 02 03 04 05 06 07 08 09 1 0
b = 11 12 13 14 15 16 17 18 19 20
c = 21 22 23 24 25 26 27 28 29 30 31
So
the formations will have 7 letters
the maximum repetition of 5 per line
aaaaabc, aaaabbc ............. bbccccc
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
something like this?

part of ... 2187 rows

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#70AD47]letters[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaaaaa[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaaaab[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaaaac[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaaaba[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaaabb[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaaabc[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaaaca[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaaacb[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaaacc[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaabaa[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaabab[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaabac[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaabba[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaabbb[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaabbc[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaabca[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaabcb[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaabcc[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaacaa[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaacab[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaacac[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaacba[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaacbb[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaacbc[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaacca[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaaaccb[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaaaccc[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaabaaa[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaabaab[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaabaac[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaababa[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaababb[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaababc[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaabaca[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaabacb[/td][/tr]

[tr=bgcolor:#FFFFFF][td]aaabacc[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]aaabbaa[/td][/tr]
[/table]
 
Last edited:
Upvote 0
hello sandy, no more than 5 letters per line, in your example there are 7
maximum of 5 for each of the lines
the order is increasing =
can not have ex = abbaa = can not
corret = aaaabb
go to bbccccc this is the last training of a maximum of 5 per line
 
Upvote 0
Perhaps:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG27Feb02
[COLOR="Navy"]Dim[/COLOR] a, Ray, nStr [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Ray = Array("a", "b", "c")

[COLOR="Navy"]For[/COLOR] n = 0 To UBound(Ray)
    [COLOR="Navy"]For[/COLOR] a = 1 To 5
        nStr = nStr & Ray(n)
    [COLOR="Navy"]Next[/COLOR] a
[COLOR="Navy"]Next[/COLOR] n

[COLOR="Navy"]For[/COLOR] n = 1 To Len(nStr) - 6
    c = c + 1
    Cells(c, 1) = Mid(nStr, n, 7)
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
aabbccc.......missing permutationscriterion = maximum 5 letters for each line, but has can not have only 9 has more permutations ai!
abbbccc? etc......
 
Upvote 0
Try this :-
Data (aaaaabbbbbccccc) in "A1:A15" Results in column "C".
Code:
[COLOR="Navy"]Sub[/COLOR] Combinations()
'[COLOR="Green"][B]Re:-Pgc01[/B][/COLOR]
[COLOR="Navy"]Dim[/COLOR] rRng [COLOR="Navy"]As[/COLOR] Range, p
[COLOR="Navy"]Dim[/COLOR] vElements, lRow [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] vresult [COLOR="Navy"]As[/COLOR] Variant
 Set rRng = Range("A1", Range("A1").End(xlDown)) '[COLOR="Green"][B] The set of numbers[/B][/COLOR]
p = 7
 
vElements = Application.Index(Application.Transpose(rRng), 1, 0)
ReDim vresult(1 To p)
Call CombinationsNP(vElements, CInt(p), vresult, lRow, 1, 1)
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
 
[COLOR="Navy"]Sub[/COLOR] CombinationsNP(vElements [COLOR="Navy"]As[/COLOR] Variant, p [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] vresult [COLOR="Navy"]As[/COLOR] Variant, lRow [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] iElement [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer,[/COLOR] iIndex [COLOR="Navy"]As[/COLOR] Integer)
[COLOR="Navy"]Dim[/COLOR] i [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
 
[COLOR="Navy"]For[/COLOR] i = iElement To UBound(vElements)
    vresult(iIndex) = vElements(i)
    [COLOR="Navy"]If[/COLOR] iIndex = p [COLOR="Navy"]Then[/COLOR]
        lRow = lRow + 1
        Range("C" & lRow) = Join(vresult, "")
    [COLOR="Navy"]Else[/COLOR]
        Call CombinationsNP(vElements, p, vresult, lRow, i + 1, iIndex + 1)
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] i
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top