VBA Data Scrape Macro Using Frequency Analysis

htmagic

New Member
Joined
Dec 2, 2009
Messages
40
Office Version
  1. 2019
Platform
  1. Windows
Hello,

Although I have lurked on this forum for some time now, this is my first technical post to the group asking for programming advice.
I have some knowledge of VBA, learning it as I go, and some of the advanced statistical functions of Excel.
Some of the posts and replies of this group have gotten me this far as a result.

I have written a program to analyze the winning Powerball Lottery numbers. The first five groups of numbers use 1-59 whereas the Powerball number is 1-35. I am using the statistical function frequency to analyze the numbers and provide me the number of times a certain number has been "pulled" for the winning number.

My question is, I am doing a data scrape using a VBA macro (called Draw) of a website. I paste this into a worksheet called WebScrape (Sheet 1) which contains this raw data.
I would like to add a button to CHECK RESULTS which updates the data from the webpage. The data results come in as one string and then I use a macro (called Parse) to parse the data into a series of two digit numbers.

VBA Code looks like this:

HTML:
Sub Draw()
'
' Draw Macro
' Scrape data from website
'

'
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.tnlottery.com/winningnumbers/default.aspx#pwrball", _
        Destination:=Range("$A$1"))
        .Name = "default.aspx#pwrball_1"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = True
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = """dgPowerBallWinners"""
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub
Sub Parse()
'
' Parse Macro
' Parse data
'
' Keyboard Shortcut: Ctrl+t
'
    Application.Goto Reference:="R2C3"
    Range(Selection, Selection.End(xlDown)).Select
    Selection.TextToColumns Destination:=ActiveCell.Offset(0, 3).Range("A1"), _
        DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter _
        :=True, Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
        Other:=True, OtherChar:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array _
        (3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), TrailingMinusNumbers:=True
End Sub

OK, now the WebScrape page looks like this:

[TABLE="width: 500"]
<tbody>[TR]
[TD]Draw Date[/TD]
[TD]
Draw Result
[/TD]
[TD]Details[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]PB[/TD]
[/TR]
[TR]
[TD]7/11/2012[/TD]
[TD]05-22-36-49-55 23[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]3[/TD]
[TD]5[/TD]
[TD]29[/TD]
[TD]39[/TD]
[TD]59[/TD]
[TD]29[/TD]
[/TR]
[TR]
[TD]7/7/2012[/TD]
[TD]03-05-29-39-59 29[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]14[/TD]
[TD]19[/TD]
[TD]35[/TD]
[TD]39[/TD]
[TD]56[/TD]
[TD]33[/TD]
[/TR]
[TR]
[TD]7/4/2012[/TD]
[TD]14-19-35-39-56 33[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]7[/TD]
[TD]15[/TD]
[TD]20[/TD]
[TD]41[/TD]
[TD]44[/TD]
[TD]22[/TD]
[/TR]
[TR]
[TD]6/30/2012[/TD]
[TD]07-15-20-41-44 22[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]6[/TD]
[TD]34[/TD]
[TD]40[/TD]
[TD]46[/TD]
[TD]58[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]6/27/2012[/TD]
[TD]06-34-40-46-58 06[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]41[/TD]
[TD]44[/TD]
[TD]53[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]6/23/2012[/TD]
[TD]01-03-41-44-53 30[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]11[/TD]
[TD]17[/TD]
[TD]29[/TD]
[TD]56[/TD]
[TD]57[/TD]
[TD]14[/TD]
[/TR]
[TR]
[TD]6/20/2012[/TD]
[TD]11-17-29-56-57 14[/TD]
[TD]details[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]14[/TD]
[TD]15[/TD]
[TD]16[/TD]
[TD]27[/TD]
[TD]26[/TD]
[/TR]
</tbody>[/TABLE]

The numbers to the right of the details are the parsed numbers. Can I do this automatically when I data scrape the webpage?

Then I have a worksheet (called Data) with the date and the winning numbers, with the Powerball (PB) number at the end. A third worksheet (called Calculations) analyzes the data table using the FREQUENCY function. On this page, I analyze the winning numbers (1-59) with a BIN (1-59) and then the Frequency (FREQ) using the following formula:

=FREQUENCY(Data!$C$2:$G$43,$B$2:$B$60)

I do a similar PB BIN (1-35) and PB FREQ for the Poweball (PB) numbers. The array works well and produces values. Then I have a column for the SORT BIN and SORT FREQ and SORT PB BIN and SORT PB FREQ. I copy and then paste the array values then sort according to FREQ, highest to lowest values.

My question here is can I append to this array, making it grow as I hit the button CHECK RESULTS, pulling the latest lottery numbers from the webpage and transferring them into the
Data worksheet? I would like to add to the array and let it grow larger as it adds more dates and numbers to the Data worksheet. Then the array would automatically update as more data is added.

I am sorry for the long post and complicated description but I cannot add my Excel file here as HTML Makeer apparently is no longer available. I also cannot post attachments.
Thank you in advance for your help on this problem.

MagicBill
 
Could you provide a Screen Shot of the "Calculations" tab. that will help me visualize what you are looking at.....

When I was testing the solution, I had the numbers 1-59 in B2:B9 on the "calculation" tabs. I had the "Frequency" formula in C2:C59 for the Draw numbers and then the Frequency function in column d2:d36 for the PB Frequencies.


Here is an explaination of the Code:

We need to move thru each row of the data from the website can copy the unique data to the "DATA" Tab. The data starts in Row two and typically has 5 entries

*WsDataRowNo = WsData.Cells(WsData.Rows.Count, "A").End(xlUp).Row + 1
*MaxDateData = Application.WorksheetFunction.Max(WsData.Columns("B:B")) Find the Maxium Date in cOLUMN B of the the "DATA"
*For WsWebRowNo = 2 To WsWeb.Cells(WsWeb.Rows.Count, "A").End(xlUp).Row

'Do not copy the Web Data to the Data Sheet unless it is new..
*If WsWeb.Cells(WsWebRowNo, "B") > MaxDateData Then

Copy Both Column A and B from the Web Data Tab to the Data Tab
*WsData.Cells(WsDataRowNo, "A") = WsWeb.Cells(WsWebRowNo, "A")
*WsData.Cells(WsDataRowNo, "B") = WsWeb.Cells(WsWebRowNo, "B")

The PB number has a space rather than a "-" before it. Add the dash to insure it is consistant with the other Draw Numbers
*Draw = Replace(WsWeb.Cells(WsWebRowNo, "C"), " ", "-")

Split the "Draw" into it 6 element Array. 5 Numbers and 1 PB
*N = Split(Draw, "-")

Place each of the 6 numbers from the array (N) to the Data tab
*For I = 0 To UBound(N)
*WsData.Cells(WsDataRowNo, 3 + I) = N(I)
*Next I

Advance to the next ROW on the Data tab
*WsDataRowNo = WsDataRowNo + 1
*End If
 
Last edited:
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Could you provide a Screen Shot of the "Calculations" tab. that will help me visualize what you are looking at.....

When I was testing the solution, I had the numbers 1-59 in B2:B9 on the "calculation" tabs. I had the "Frequency" formula in C2:C59 for the Draw numbers and then the Frequency function in column d2:d36 for the PB Frequencies.

Mr. Downey,

Here is a copy of the screen shot for the Calculations worksheet.


-- removed inline image ---



You are correct where I had the BIN and Frequency formulas. You can also see that I then copy the BIN and FREQ and paste these values into columns E and F. These are the SORT BIN (1-59) and SORT FREQ columns. I sort them on FREQ highest to lowest. I also copy the PB BIN (1-35) and PB FREQ and paste these values in columns G and H. I sort these highest to lowest.

Now my next question is if a macro can be used to do this action automatically? I was just going to do the steps manually while recording macro and see if I could automate this feature.

I really appreciate the explanation of the Code. Not only does it help me understand the code better, I believe it will help others that struggle with VBA. I would have never thought of writing a query table and deleting it afterwards.

Thank you again for your assistance and explanation.

MagicBill
 
Last edited:
Upvote 0
Unfortunally, I am not able to see the image. Mabey you can put it on Google Docs and provide a link.

To your question "Now my next question is if a macro can be used to do this action automatically?"... The answer is Yes, but I need to see the Screen because we need to get the Frequency Function working correctly first and I am having a hard time visualizing what you are describing.

Deleting an recreating the Query is not the most efficient way of doing things, but it does prevent multiple Query Table being assoicaited with the WorkBook.
 
Upvote 0
Mr. Downey,

I tried copying and pasting a screen shot but it did not work.

Try this for the Calculations Worksheet:

[TABLE="class: grid, width: 474"]
<tbody>[TR]
[TD="align: center"]
[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[TD="align: center"]G[/TD]
[TD="align: center"]H[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"] ___[/TD]
[TD="align: center"]BIN[/TD]
[TD="align: center"]FREQ.[/TD]
[TD="align: center"]PB FREQ.[/TD]
[TD="align: center"]SORT BIN[/TD]
[TD="align: center"]SORT FREQ[/TD]
[TD="align: center"]SORT BIN[/TD]
[TD="align: center"]SORT PB FREQ[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"][/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"][/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]27[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: center"]10[/TD]
[TD="align: center"][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD="align: center"][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]0[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]2[/TD]
[/TR]
</tbody>[/TABLE]

And so on. BIN starts in Column B as Column A is blank.

Now on the Data Worksheet, a sample looks like this:

[TABLE="class: grid, width: 300"]
<tbody>[TR]
[TD]Powerball[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]PB[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/14/2012[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]37[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/11/2012[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]36[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]55[/TD]
[TD="align: right"]23[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/7/2012[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]29[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/4/2012[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]33[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/30/2012[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]44[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/27/2012[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/23/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]44[/TD]
[TD="align: right"]53[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/13/2012[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]57[/TD]
[TD="align: right"]18[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/9/2012[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]57[/TD]
[TD="align: right"]27[/TD]
[/TR]
</tbody>[/TABLE]

Now when I use the formula,
Code:
[COLOR=#0000ff]=FREQUENCY(Data!$C$2:$G$43,B2:B60)[/COLOR]
, it comes out correct as above with FREQ. of 6 for BIN 1, 0 for BIN 2, 3 for BIN 3, etc.

When I use
Code:
[COLOR=#0000ff]=FREQUENCY(DrawRng,B2:B60)[/COLOR]
, it does not return the same values. I even used Data! in front of DrawRng thinking that it may have been on the Data worksheet.

Thanks again for bearing with me on this.

MagicBill
 
Upvote 0
I notice that your Frequency formula extends thru G43, But the data you shows 9 rows of actual data.

Code:
[COLOR=#0000ff]=FREQUENCY(Data!$C$2:$G$43,B2:B60)[/COLOR]</PRE>

06/09/2012 is the last data element provided. Is there more data that is in the sheet that is not shown?

Also, When you entered the "Array" Frequency Formula in was it entered via the "Ctrl-Shift-Enter" sequence to all of the cells in the Range C2:C60. It is critical that it be entered as an Array Formula to all the cells and not just a formula. When you look at it in the "Edit Bar" is should have {} on either end (i.e. {=frequency(....)}

Also, if you select the pull down next to the Edit Bar, you should be able to see the two named ranges (DataRng and PBRang). Selecting one should show you the actual cells that the range represents. Is that range correct.

Finally, If we are still having issues after you check all of this, I'll just write some code to fill in the Array Formula in the Calc Sheet
 
Upvote 0
Here is the code that adds the Array Formulas to the "Calculations" Worksheet

Code:
Option Explicit
Sub Process()
    Dim WsWeb As Worksheet
    Dim WsData As Worksheet
    Dim WsCalc As Worksheet
    Dim qt As QueryTable
    
    Dim WsWebRowNo As Long
    Dim WsDataRowNo As Long
    Dim Draw As String
    Dim N As Variant
    Dim I As Integer
    
    Dim MaxDateData As Date
    
    Set WsWeb = ThisWorkbook.Worksheets("WebScrape")
    Set WsData = ThisWorkbook.Worksheets("Data")
    Set WsCalc = ThisWorkbook.Worksheets("Calculations")
    
    'Extract the informationn from the website
    Call DeleteQT
    WsWeb.Cells.Clear
    Call DrawNumbers
    Set qt = WsWeb.QueryTables(1)
    
    WsDataRowNo = WsData.Cells(WsData.Rows.Count, "A").End(xlUp).Row + 1
    MaxDateData = Application.WorksheetFunction.Max(WsData.Columns("B:B"))
    For WsWebRowNo = 2 To WsWeb.Cells(WsWeb.Rows.Count, "A").End(xlUp).Row
        If WsWeb.Cells(WsWebRowNo, "B") > MaxDateData Then
            WsData.Cells(WsDataRowNo, "A") = WsWeb.Cells(WsWebRowNo, "A")
            WsData.Cells(WsDataRowNo, "B") = WsWeb.Cells(WsWebRowNo, "B")
            
            Draw = Replace(WsWeb.Cells(WsWebRowNo, "C"), " ", "-")
            N = Split(Draw, "-")
            For I = 0 To UBound(N)
                WsData.Cells(WsDataRowNo, 3 + I) = N(I)
            Next I
            
            WsDataRowNo = WsDataRowNo + 1
        End If
    Next
    
    WsDataRowNo = WsData.Cells(WsData.Rows.Count, "A").End(xlUp).Row
    
    ThisWorkbook.Names.Add Name:="DrawRng", RefersToR1C1:="=Data!R2C3:R" & WsDataRowNo & "C7"
    ThisWorkbook.Names.Add Name:="PbRng", RefersToR1C1:="=Data!R2C8:R" & WsDataRowNo & "C8"
    
    
    Call UpdateCalcWS(WsCalc)
End Sub
Function UpdateCalcWS(WsCalc As Worksheet)
    'Add Formula Arrays to Caculations WorkSheet
    WsCalc.Range("C2:C60").FormulaArray = "=FREQUENCY(DrawRng,RC[-1]:R[58]C[-1])"
    WsCalc.Range("D2:D36").FormulaArray = "=FREQUENCY(pbRng,RC[-2]:R[34]C[-2])"
End Function
Function DrawNumbers()
    Dim WS As Worksheet
    
    Set WS = ThisWorkbook.Worksheets("WebScrape")
    With WS.QueryTables.Add(Connection:= _
        "URL;http://www.tnlottery.com/winningnumbers/default.aspx#pwrball", Destination:=WS.Range("$A$1"))
        .Name = "pwrball"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "dgPowerBallWinners"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Function
Function DeleteQT()
    Dim qt As QueryTable
    For Each qt In ThisWorkbook.Worksheets("WebScrape").QueryTables
        qt.Delete
    Next
End Function
 
Upvote 0
I notice that your Frequency formula extends thru G43, But the data you shows 9 rows of actual data.

Code:
[COLOR=#0000ff]=FREQUENCY(Data!$C$2:$G$43,B2:B60)[/COLOR]

06/09/2012 is the last data element provided. Is there more data that is in the sheet that is not shown?

Yes, that is why I said and so on. Actual Data Worksheet is as follows:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Powerball[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: center"]PB[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/14/2012[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]37[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]13[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/11/2012[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]36[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]55[/TD]
[TD="align: right"]23
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/7/2012[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]29[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]7/4/2012[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]33[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/30/2012[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]44[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/27/2012[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/23/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]44[/TD]
[TD="align: right"]53[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/13/2012[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]57[/TD]
[TD="align: right"]18[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/9/2012[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]57[/TD]
[TD="align: right"]27[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/6/2012[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]48[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]27[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]6/2/2012[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]33[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/30/2012[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]52[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/26/2012[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/23/2012[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]26[/TD]
[TD="align: right"]53[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]32[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/19/2012[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]51[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/16/2012[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]21[/TD]
[TD="align: right"]28[/TD]
[TD="align: right"]43[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/12/2012[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]53[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/9/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]55[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/5/2012[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]44[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]23[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]5/2/2012[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]38[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]29[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/28/2012[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]40[/TD]
[TD="align: right"]57[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]33[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/25/2012[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]25[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]34[/TD]
[TD="align: right"]43[/TD]
[TD="align: right"]29[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/21/2012[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]51[/TD]
[TD="align: right"]16[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/18/2012[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]22[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]29[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/14/2012[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/11/2012[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]23[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]44[/TD]
[TD="align: right"]47[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/7/2012[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]18[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]4/4/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/31/2012[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]36[/TD]
[TD="align: right"]54[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]27[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/28/2012[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]33[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/24/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]37[/TD]
[TD="align: right"]47[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/21/2012[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]43[/TD]
[TD="align: right"]53[/TD]
[TD="align: right"]55[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/17/2012[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]55[/TD]
[TD="align: right"]58[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/14/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]24[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/10/2012[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]41[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/7/2012[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]47[/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]3/3/2012[/TD]
[TD="align: right"]29[/TD]
[TD="align: right"]30[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]47[/TD]
[TD="align: right"]49[/TD]
[TD="align: right"]35[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]2/29/2012[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]23[/TD]
[TD="align: right"]26[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]2/25/2012[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]42[/TD]
[TD="align: right"]53[/TD]
[TD="align: right"]54[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]2/22/2012[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]39[/TD]
[TD="align: right"]51[/TD]
[TD="align: right"]32[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]2/18/2012[/TD]
[TD="align: right"]23[/TD]
[TD="align: right"]28[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="align: right"]2/15/2012[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]32[/TD]
[TD="align: right"]52[/TD]
[TD="align: right"]56[/TD]
[TD="align: right"]11[/TD]
[/TR]
</tbody>[/TABLE]

And it will continue to grow as new numbers are posted on the website. This is why I wanted a table that grew.

Also, When you entered the "Array" Frequency Formula in was it entered via the "Ctrl-Shift-Enter" sequence to all of the cells in the Range C2:C60. It is critical that it be entered as an Array Formula to all the cells and not just a formula. When you look at it in the "Edit Bar" is should have {} on either end (i.e. {=frequency(....)}

Exactly. I am aware of this but it still returns different frequency values.

Also, if you select the pull down next to the Edit Bar, you should be able to see the two named ranges (DataRng and PBRang). Selecting one should show you the actual cells that the range represents. Is that range correct.

Finally, If we are still having issues after you check all of this, I'll just write some code to fill in the Array Formula in the Calc Sheet
Aha! The ranges were wrong! For DrawRng, the range is =Data!$C$1:$G$2. It should be =Data!$C$2:$G$43 and keep growing as more entries are posted on the website.
Similarly, for PbRng, the range is =Data!$H$1:$H$2. It should be =Data!$H$2:$H$43 and keep growing as more entries are posted on the website.

Once I fixed the ranges, the results are identical to what I had before. Excellent! Thank you for this information! I know most lottery analyzers use a random number generator to generate winning numbers, but this spreadsheet analyzes the recurring numbers in an ever growing array. The idea being is to play the most frequently used numbers to increase your chances.

Thanks again for your tutoring. I'll have to send you a copy of my spreadsheet once it is finished so you can play with it. I'm looking at the Tennessee lottery but with more work, one could fancy this up with a drop down menu to select other states and have a look-up table do the web addresses.

Now to address the sorting in a macro problem...

MagicBill
 
Upvote 0
So does the last code that I sent work correctly for the Calculations on the for the Freq and PB distribution?
 
Upvote 0
Yes! Thank you!

MagicBill

Actually, let me rephrase that. When I run the macro, it reverts back to the original ranges which start in row 1. They should start in row 2 and end in row 43. So we need to redefine the range names.
So where in the macro do I change the range size to the larger value?

MagicBill
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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