I turn to you because I have a question.
The following document lists the extracted numbers and a generated list.
I ran into drawing lots of numbers that had already been played.
How could the number strings that have already been drawn be filtered out in the generator?
According to your attachment as a VBA beginner starter using some Excel basics :
PHP Code:
Sub Demo1() Dim V, W, X, P%, R%, Y, J$, S$(1 To 101), L%, Z(1 To 101) V = Array([COLUMN(A:G)], [COLUMN(H:N)], [COLUMN(O:U)], [COLUMN(V:AB)], [COLUMN(AC:AI)]) W = [COLUMN(A:AI)] X = Munka1.[C3:C103&"-"&D3:D103&"-"&E3:E103&"-"&F3:F103&"-"&G3:G103&"-"&H3:H103&"-"&I3:I103] Randomize Do For P = 35 To 8 Step -1 R = Fix(Rnd * P) + 1: Y = W(R): W(R) = W(P): W(P) = Y Next For Each Y In V Y = Application.Small(Application.Index(W, , Y), V(0)) J = Join(Y, "-") If IsError(Application.Match(J, X, 0)) Then If IsError(Application.Match(J, S, 0)) Then L = L + 1: S(L) = J: Z(L) = Y If L = 101 Then Munka1.[L3:R103] = Application.Index(Z, [ROW(1:101)], V(0)): Exit Sub End If End If Next Loop End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Last edited by Marc L; 07-26-2020 at 05:01 PM.
Reason: revamped for more Excel basics …
Re: Lottery numbers generator without history numbers
Hi Marc L
Thank you very much for your solution.
But I still want to ask you to enlighten me please as I don’t understand much about the vba.
I mean:
You have created an array (v) in which you have added columns: (a: i, h: n, o: u, v: ab, ac: ai) that do not even contain data. How and why?
Or (w) is all of the above, but why?
I mean (x).
Why does (p) count to 35-8?
(R) also causes headaches.
In any case, thank you for your solution, if you had a book or a link to a solution to this case, from which I can understand why and how it is here, I would thank you.
All I guessed was that you had to work with an array,
but there would be nothing that would help my studies as well.
One where the generation of seven numbers can be handled separately?
I also put together the original by learning a lot from it. And for me, rewriting is also easier for another type if I handle it separately.
If you could help me with that, I would also like to thank you.
Re: Lottery numbers generator without history numbers
Thanks for the rep' !
Variant variable V does not contains columns but a numbers array as you can check yourself
in debugging mode in the VBE Locals window - the best way to learn what the procedure does - like for example
V(0) is equal to {1,2,3,4,5,6,7} and that's the same for variant variable W which contains an array from 1 to 35 …
So the For P = 35 to 8 … shuffles the W array for 5 series of 7 numbers thus avoiding any duplicate number
and variable R is just a random number …
Bookmarks