PDA

View Full Version : Sleeper: Adding a subroutine to a macro already done.



b_rianv
08-10-2014, 12:27 PM
Hello all

I would like to add a "subroutine" to my macro to show the numbers it is picking. But I am having a problem figuring out how to do this.. Here is my macro...


Sub generatelottery2()

Const l& = 1 'lower value
Const u& = 49 'upper value
Const n& = 6 'number of numbers per draw
Dim a(), b() As Boolean
Dim rws&, i&, x&, k&
rws = 20 'number of lottery draws
ReDim a(1 To rws, 1 To n)

Randomize
For i = 1 To rws
ReDim b(l To u): k = 0: s = ""
Do
x = Int(Rnd * u) + l
If Not b(x) Then k = k + 1: b(x) = True
Loop Until k = n
k = 0
For x = l To u
If b(x) Then k = k + 1: a(i, k) = x
Next x
Next i
Range("C1").Resize(rws, n) = a
With Range("A1").Resize(rws)
.Cells = "=""Draw "" & row()"
.Value = .Value
End With
End Sub

I would like to be able to do add this in to the macro...
Change 50000 For k = 1 To 50000 to change time delay
'to either a smaller or larger number to speed up or slow down.

For k = 1 To 50000
dum = (dum * k) ^ 5
Next k
DoEvents

But I have "k" already doing something.

Can someone teach me how to do this??

Thank you,

Bob Phillips
08-10-2014, 02:49 PM
I am totally lost as to what that macro is supposed to do, and what you want it to do, as you say show the numbers it is picking, but ask how to slow it down (and what is dum?).