<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
	<channel>
		<title>Excel VBA script to generate a list of 5 randomized draws (forum requested)</title>
		<link>/blogentry/52317</link>
		<atom:link href="https://www.lotterypost.com/rss/blogcomments/52317" rel="self" type="application/rss+xml" />
		<description>LottoMining's Blog: Excel VBA script to generate a list of 5 randomized draws (forum requested)</description>
		<dc:language>en-us</dc:language>
		<generator>Lottery Post RSS Generator</generator>
		<item>
			<title>Comment #2</title>
			<link>/blogentry/52317#c60576</link>
			<guid isPermaLink="true">/blogentry/52317#c60576</guid>
			<pubDate>Fri, 18 Mar 2011 12:38:07 GMT</pubDate>
			<dc:creator>LottoMining</dc:creator>
			<description><![CDATA[<p>You&#x27;re welcome; hope you win with it.</p>]]></description>
			<category>LottoMining</category>
		</item>
		<item>
			<title>Comment #1</title>
			<link>/blogentry/52317#c60546</link>
			<guid isPermaLink="true">/blogentry/52317#c60546</guid>
			<pubDate>Thu, 17 Mar 2011 15:11:53 GMT</pubDate>
			<dc:creator>budward</dc:creator>
			<description><![CDATA[<p>thanks LottoMining! I&#x27;ve already adapted it to my style and am going to start using it for predictions tomorrow to see what happens.</p>]]></description>
			<category>budward</category>
		</item>
		<item>
			<title>Original Blog Entry: Excel VBA script to generate a list of 5 randomized draws (forum requested)</title>
			<link>/blogentry/52317</link>
			<guid isPermaLink="true">/blogentry/52317</guid>
			<pubDate>Thu, 17 Mar 2011 03:02:27 GMT</pubDate>
			<dc:creator>LottoMining</dc:creator>
			<description><![CDATA[<p>A recent LP forum topic requested a script of some kind to generate randomized picks from the user&#x27;s defined list of numbers. I wrote (a number of years prior) an Excel VBA script that does this. The script needs a tab labeled Last and then you put your list in the K column. One interesting aspect to the macro is that let&#x27;s say you think digit 39 is very likely to come up so you list it two, three times or more in the list and you&#x27;ll see it show up more often in the outputted list of 5 randomized draws at range M1:Q5. The script can be modified to output to generate more randomized draws and the intUniq variable can be changed to allow more or less numbers in your pool to randomize have the draws all be lower than a specified number, etc. Once again, I used/borrowed the BubbleSort sub from John Walkenbach, who has written several great books on Excel and VBA for Excel; this sub sorts arrays, a handy function indeed. I forget the reasons why goto statements are frowned upon, though I&#x27;ve stopped using them myself; forgive me if they offend your programming sensibilities.<br /><br />Sub GenerateFiveRandDraws()<br /><br />Dim x As Single, intDrw As Integer, ColRef As String, NumDy As Integer, sCol As String<br /><br />Dim LastC5ol As String, intUniq As Integer, strDblChk As String, ChkRef As String, ArNums(1 To 5) As Integer<br /><br />Dim Val1 As Integer, Val2 As Integer, Val3 As Integer, Val4 As Integer, Val5 As Integer, a As Integer, ValX As Integer<br /><br />Dim rndstart As Single, intrndstart As Integer<br /><br />Sheets( Last ).Select<br /><br />NumDy = 1<br /><br />Do<br /><br />intDrw = 1<br /><br />Do<br /><br />ColRef = Switch(intDrw = 1, M , intDrw = 2, N , intDrw = 3, O , intDrw = 4, P , intDrw = 5, Q )<br /><br />&#x27;accept RndNum iif it&#x27;s in the list in Col, then test for no dupes<br /><br />intUniq = 1<br /><br />DoOVER:<br /><br />Do<br /><br />&#x27;&#x27;&#x27;double rnd to start at different areas in UniqNums array<br /><br />rndstart = Format((Rnd() * 0.31) * 100, 00 )<br /><br />intrndstart = CInt(rndstart)<br /><br />intUniq = intrndstart + 1<br /><br />x = Format((Rnd() * 0.39) * 100, 00 )<br /><br />LastCol = K CStr(intUniq)<br /><br />intUniq = intUniq + 1<br /><br />If intUniq 27 Then &#x27;&#x27;&#x27;chng to 26 from 30<br /><br />intUniq = 1<br /><br />End If<br /><br />&#x27;&#x27;&#x27;&#x27;embed a check here/perhaps send to sub w/more bias checks<br /><br />If x = 0 Then<br /><br />GoTo DoOVER<br /><br />End If<br /><br />Loop Until x = Range(LastCol).Value<br /><br />sCol = ColRef CStr(NumDy)<br /><br />Range(sCol).Value = x<br /><br />If intD5rw 1 Then<br /><br />ChkRef = Switch(intDrw = 2, M , intDrw = 3, N , intDrw = 4, O , intDrw = 5, P )<br /><br />strDblChk = ChkRef CStr(NumDy)<br /><br />If Range(strDblChk).Value = Range(sCol).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 3 And Range(sCol).Value = Range( N CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 3 And Range(sCol).Value = Range( M CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 4 And Range(sCol).Value = Range( N CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 4 And Range(sCol).Value = Range( M CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 5 And Range(sCol).Value = Range( P CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 5 And Range(sCol).Value = Range( O CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 5 And Range(sCol).Value = Range( N CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />ElseIf intDrw = 5 And Range(sCol).Value = Range( M CStr(NumDy) ).Value Then<br /><br />GoTo DoOVER<br /><br />End If<br /><br />End If<br /><br />intDrw = intDrw + 1<br /><br />Loop Until intDrw 5<br /><br />Val1 = Range( M CStr(NumDy) ).Value<br /><br />Val2 = Range( N CStr(NumDy) ).Value<br /><br />Val3 = Range( O CStr(NumDy) ).Value<br /><br />Val4 = Range( P CStr(NumDy) ).Value<br /><br />Val5 = Range( Q CStr(NumDy) ).Value<br /><br />For a = 1 To 5<br /><br />ValX = Switch(a = 1, Val1, a = 2, Val2, a = 3, Val3, a = 4, Val4, a = 5, Val5)<br /><br />ArNums(a) = ValX<br /><br />Next<br /><br />a = a - 1<br /><br />Call BubbleSort(ArNums())<br /><br />Range( Q CStr(NumDy) ).Value = ArNums(a)<br /><br />Range( P CStr(NumDy) ).Value = ArNums(a - 1)<br /><br />Range( O CStr(NumDy) ).Value = ArNums(a - 2)<br /><br />Range( N CStr(NumDy) ).Value = ArNums(a - 3)<br /><br />Range( M CStr(NumDy) ).Value = ArNums(a - 4)<br /><br />If Range( M CStr(NumDy) ).Value = Range( N CStr(NumDy) ).Value Then<br /><br />intDrw = 1<br /><br />GoTo DoOVER<br /><br />ElseIf Range( N CStr(NumDy) ).Value = Range( O CStr(NumDy) ).Value Then<br /><br />intDrw = 2<br /><br />GoTo DoOVER<br /><br />ElseIf Range( O CStr(NumDy) ).Value = Range( P CStr(NumDy) ).Value Then<br /><br />intDrw = 3<br /><br />GoTo DoOVER<br /><br />ElseIf Range( P CStr(NumDy) ).Value = Range( Q CStr(NumDy) ).Value Then<br /><br />intDrw = 4<br /><br />GoTo DoOVER<br /><br />End If<br /><br />NumDy = NumDy + 1<br /><br />Loop Until NumDy 5<br /><br />MsgBox done<br /><br />End Sub<br /><br />&#x27;borrowed this from John Walkenbach, a writer of great Excel books<br /><br />Sub BubbleSort(list() As Integer)<br /><br />Dim First As Integer, Last As Integer, i As Integer, j As Integer, temp<br /><br />First = LBound(list)<br /><br />Last = UBound(list)<br /><br />For i = First To Last - 1<br /><br />For j = i + 1 To Last<br /><br />If list(i) list(j) Then<br /><br />temp = list(j)<br /><br />list(j) = list(i)<br /><br />list(i) = temp<br /><br />End If<br /><br />Next j<br /><br />Next i<br /><br />End Sub<br /><br />... &#x5b;&#xa0;<a href="/blogentry/52317">More</a>&#xa0;&#x5d;</p>]]></description>
			<category>Blog Entry</category>
			<category>LottoMining</category>
			<wfw:comment>https://www.lotterypost.com/blogentry/52317</wfw:comment>
		</item>
	</channel>
</rss>

