Advertisement
Brovashift

Untitled

May 19th, 2023
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private racecardSheetName As String
  2. Private dataSheetName As String
  3. Private horseData As Object
  4.  
  5. Private Sub ComboBox1_Change()
  6.     Dim selectedValue As String
  7.     Dim item As listItem
  8.     Dim newItem As listItem
  9.    
  10.     selectedValue = ComboBox1.value
  11.    
  12.     ListView2.ListItems.Clear
  13.    
  14.     ' Assuming the column you want to filter is column 4
  15.    For Each item In ListView2.ListItems
  16.         If item.ListSubItems(4).Text = selectedValue Or selectedValue = "All" Then
  17.             Set newItem = ListView2.ListItems.Add(, , item.Text)
  18.             newItem.ListSubItems(1) = item.ListSubItems(1)
  19.             ' Add more subitems as needed
  20.        End If
  21.     Next item
  22. End Sub
  23.  
  24. Private Sub PopulateComboBox()
  25.  
  26.     ComboBox1.Clear
  27.     Dim item As listItem
  28.     Dim columnValue As String
  29.     Dim itemExists As Boolean
  30.    
  31.     ' Assuming the column you want to extract values from is column 5 (index 4)
  32.    For Each item In ListView2.ListItems
  33.         columnValue = item.ListSubItems(4).Text
  34.        
  35.         ' Check if the value already exists in ComboBox
  36.        itemExists = False
  37.         For i = 0 To ComboBox1.ListCount - 1
  38.             If ComboBox1.List(i) = columnValue Then
  39.                 itemExists = True
  40.                 Exit For
  41.             End If
  42.         Next i
  43.        
  44.         ' Add the value to ComboBox if it doesn't exist
  45.        If Not itemExists Then
  46.             ComboBox1.AddItem columnValue
  47.         End If
  48.     Next item
  49. End Sub
  50.  
  51. Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)
  52.     ' Check if the edit is being performed on the first column (index 1) of ListView1
  53.    If ListView1.ColumnHeaders(1).Index = 1 Then
  54.         ' Cancel the label edit event
  55.        Cancel = True
  56.     End If
  57. End Sub
  58.  
  59. Private Sub ListView2_BeforeLabelEdit(Cancel As Integer)
  60.     ' Check if the edit is being performed on the first column (index 1) of ListView2
  61.    If ListView2.ColumnHeaders(1).Index = 1 Then
  62.         ' Cancel the label edit event
  63.        Cancel = True
  64.     End If
  65. End Sub
  66.  
  67. Private Sub ListView1_ItemClick(ByVal item As MSComctlLib.listItem)
  68.  
  69.     ' Get the horse name from the clicked item
  70.    Dim horseName As String
  71.     horseName = item.Text ' Assuming horse name is stored in the first column
  72.    
  73.     ' Populate child ListView with data from Sheet2
  74.    PopulateChildListView horseName
  75.  
  76. End Sub
  77.  
  78. Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
  79.     On Error Resume Next
  80.    
  81.     ' Get the currently edited node
  82.    Dim editedNode As Node
  83.     Set editedNode = TreeView1.SelectedItem
  84.    
  85.     ' Check if the edited node is a parent or child node
  86.    If Err.Number <> 0 Then
  87.         ' Error occurred, cancel the label edit
  88.        Cancel = True
  89.     ElseIf editedNode.Child <> "" Or editedNode.Parent <> "" Then
  90.         ' Cancel the label edit
  91.        Cancel = True
  92.     End If
  93.    
  94.     On Error GoTo 0
  95. End Sub
  96.  
  97.  
  98.  
  99.  
  100.  
  101. Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
  102.    
  103.     ' Clear existing items from parent ListView
  104.    ListView2.ListItems.Clear
  105.    
  106.     ' Declare variables
  107.    Dim raceCourse As String
  108.     Dim raceTime As String
  109.     Dim targetSheet As Worksheet
  110.     Dim targetRow As Long
  111.     Dim offTime As Date
  112.     Dim course As String
  113.     Dim raceName As String
  114.     Dim raceDate As Date
  115.     Dim prizeMoney As String
  116.     Dim formattedPrizeMoney As String
  117.     Dim regex As Object
  118.     Dim raceDist As String
  119.     Dim raceClass As String
  120.     Dim raceType As String
  121.     Dim going As String
  122.     Dim fieldSize As String
  123.    
  124.     ' Check if clicked node is a child node
  125.    If Not Node.Parent Is Nothing Then
  126.        
  127.         ' Get race course and race time from clicked nodes
  128.        raceCourse = Node.Parent.Text
  129.         raceTime = Node.Text
  130.        
  131.         ' Set target sheet
  132.        Set targetSheet = Worksheets(racecardSheetName)
  133.        
  134.         ' Find match in column B
  135.        On Error Resume Next
  136.         targetRow = targetSheet.Evaluate("match(timevalue(""" & raceTime & """),b:b,0)")
  137.         On Error GoTo 0
  138.        
  139.         If targetRow <> 0 Then
  140.            
  141.             ' Get race data from target row
  142.            offTime = targetSheet.Cells(targetRow, 2).value
  143.             course = targetSheet.Cells(targetRow, 3).value
  144.             raceName = targetSheet.Cells(targetRow, 4).value
  145.             raceDate = dateValue(targetSheet.Cells(targetRow, 1).value)
  146.             prizeMoney = targetSheet.Cells(targetRow, 10).value
  147.             raceDist = targetSheet.Cells(targetRow, 5).value
  148.             raceClass = targetSheet.Cells(targetRow, 6).value
  149.             raceType = targetSheet.Cells(targetRow, 7).value
  150.             going = targetSheet.Cells(targetRow, 9).value
  151.             fieldSize = targetSheet.Cells(targetRow, 8).value
  152.            
  153.             ' Create a regular expression object
  154.            Set regex = CreateObject("VBScript.RegExp")
  155.             With regex
  156.                 .Pattern = "\D" ' Match any non-digit character
  157.                .Global = True ' Match all occurrences
  158.            End With
  159.            
  160.             ' Remove non-numeric characters from prizeMoney
  161.            prizeMoney = regex.Replace(prizeMoney, "")
  162.             formattedPrizeMoney = "£" & Format(Val(prizeMoney), "#,##0")
  163.            
  164.             ' Display race data in labels
  165.            TimeLbl.Caption = Format(offTime, "h:mm")
  166.             CourseLbl.Caption = course
  167.             RaceNameLbl.Caption = raceName
  168.             DateLbl.Caption = Format(raceDate, "dd mmm yy")
  169.             prizeLbl.Caption = formattedPrizeMoney
  170.             distLbl.Caption = raceDist & "f"
  171.             classLbl.Caption = raceClass
  172.             raceTypeLbl = raceType
  173.             goingLbl = going
  174.             runnersLbl = fieldSize
  175.            
  176.            
  177.             ' Populate parent ListView with data from Sheet1
  178.            PopulateParentListView raceCourse, raceTime
  179.            
  180.            
  181.         Else
  182.             ' Display error message if no match was found
  183.            MsgBox "No race found for " & raceTime & " at " & raceCourse
  184.         End If
  185.  
  186.     End If
  187.    
  188. End Sub
  189. Private Sub PopulateParentListView(ByVal raceCourseName As String, ByVal raceTime As String)
  190.     ' Clear existing items from parent ListView
  191.    ListView1.ListItems.Clear
  192.    
  193.     ' Set the target sheet
  194.    Dim targetSheet As Worksheet
  195.     Set targetSheet = Worksheets(racecardSheetName)
  196.    
  197.     ' Create dictionary to store horse names and row numbers
  198.    'Dim horseData As Object
  199.    Set horseData = CreateObject("Scripting.Dictionary")
  200.    
  201.     ' Populate horse data dictionary based on raceCourseName and raceTime
  202.    Dim lastRow As Long
  203.     lastRow = targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Row
  204.    
  205.     Dim i As Long
  206.     For i = 2 To lastRow
  207.         Dim key As String
  208.         key = raceCourseName & "_" & raceTime
  209.        
  210.         If Trim(targetSheet.Cells(i, 3).value) = Trim(raceCourseName) And Format(targetSheet.Cells(i, 2).value, "h:mm") = Format(timeValue(raceTime), "h:mm") Then
  211.             Dim horseName As String
  212.             horseName = targetSheet.Cells(i, 12).value
  213.            
  214.             ' Add horse name and row number to horse data dictionary
  215.            horseData(horseName) = i
  216.         End If
  217.     Next i
  218.    
  219.     ' Populate parent ListView using horse data dictionary
  220.    Dim horseNameKey As Variant
  221.     For Each horseNameKey In horseData.Keys
  222.         Dim rowIndex As Long
  223.         rowIndex = horseData(horseNameKey)
  224.        
  225.         Dim listItem As MSComctlLib.listItem
  226.         Set listItem = ListView1.ListItems.Add(, , horseNameKey) ' Column 1
  227.        
  228.         ' Add additional subitems
  229.        listItem.SubItems(1) = targetSheet.Cells(rowIndex, 28).value ' Column 2
  230.        listItem.SubItems(2) = targetSheet.Cells(rowIndex, 11).value ' Column 3
  231.        listItem.SubItems(3) = targetSheet.Cells(rowIndex, 22).value ' Column 4
  232.        listItem.SubItems(4) = targetSheet.Cells(rowIndex, 23).value ' Column 5
  233.        listItem.SubItems(5) = targetSheet.Cells(rowIndex, 24).value ' Column 6
  234.        listItem.SubItems(6) = targetSheet.Cells(rowIndex, 25).value ' Column 7
  235.        listItem.SubItems(7) = targetSheet.Cells(rowIndex, 26).value ' Column 8
  236.        listItem.SubItems(8) = targetSheet.Cells(rowIndex, 21).value ' Column 9
  237.        listItem.SubItems(9) = targetSheet.Cells(rowIndex, 27).value ' Column 10
  238.        listItem.SubItems(10) = targetSheet.Cells(rowIndex, 17).value ' Column 11
  239.        listItem.SubItems(11) = targetSheet.Cells(rowIndex, 19).value ' Column 12
  240.        ' Add more subitems as needed
  241.        
  242.         ' Additional settings optional data
  243.        listItem.SubItems(12) = targetSheet.Cells(rowIndex, 13).value ' Column 13
  244.        listItem.SubItems(13) = targetSheet.Cells(rowIndex, 15).value ' Column 14
  245.        listItem.SubItems(14) = targetSheet.Cells(rowIndex, 16).value ' Column 15
  246.        listItem.SubItems(15) = targetSheet.Cells(rowIndex, 18).value ' Column 16
  247.        listItem.SubItems(16) = targetSheet.Cells(rowIndex, 20).value ' Column 17
  248.        
  249.     Next horseNameKey
  250.    
  251.     PopulateChildListView horseData '************************************************************************************************
  252.    
  253. End Sub
  254. Sub PopulateChildListView(Optional ByVal horseName As Variant, Optional ByVal horseData As Object)
  255.     ' Clear existing items from child ListView
  256.    ListView2.ListItems.Clear
  257.    
  258.     ' Set the target sheet (Sheet2)
  259.    Dim targetSheet As Worksheet
  260.     Set targetSheet = Worksheets(dataSheetName) ' Replace "Sheet2" with the actual name of the sheet
  261.    
  262.     ' Find the last row in Sheet2
  263.    Dim lastRow As Long
  264.     lastRow = targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Row
  265.    
  266.     ' Flag variable to indicate if any matching data is found
  267.    Dim matchFound As Boolean
  268.     matchFound = False
  269.    
  270.     If TypeName(horseName) = "String" Then
  271.         ' Loop through the rows in Sheet2 and populate the ChildListView with matching data
  272.        Dim i As Long
  273.         For i = 2 To lastRow ' Assuming the data starts from row 2
  274.            Dim horseNameSheet2 As String
  275.             horseNameSheet2 = targetSheet.Cells(i, 22).value ' Assuming the horse name is in the first column of Sheet2
  276.            
  277.             ' Remove the region letters from the horse name in Sheet2
  278.            Dim regionPos As Integer
  279.             regionPos = InStr(horseNameSheet2, "(")
  280.             If regionPos > 0 Then
  281.                 horseNameSheet2 = Trim(left(horseNameSheet2, regionPos - 1))
  282.             End If
  283.            
  284.             ' Compare the horse names
  285.            If StrComp(horseNameSheet2, horseName, vbTextCompare) = 0 Then
  286.                 Dim listItem As MSComctlLib.listItem
  287.                 Set listItem = ListView2.ListItems.Add(, , targetSheet.Cells(i, 1).value) ' Assuming the data you want to display is in the second column of Sheet2
  288.                
  289.                 ' Call the subroutine to add subitems
  290.                AddListViewSubItems listItem, targetSheet, i
  291.                
  292.                 matchFound = True ' Set the flag to indicate a match was found
  293.            End If
  294.         Next i
  295.     ElseIf TypeName(horseName) = "Dictionary" Then
  296.         ' Loop through the horse names in the dictionary and retrieve matching rows from Sheet2
  297.        Dim horseNameKey As Variant
  298.         For Each horseNameKey In horseName.Keys
  299.             Dim horseNameValue As String
  300.             horseNameValue = CStr(horseNameKey)
  301.            
  302.             ' Loop through the rows in Sheet2 and populate the ChildListView with matching data
  303.            Dim x As Long
  304.             For x = 2 To lastRow ' Assuming the data starts from row 2
  305.                Dim horseNameSheet22 As String
  306.                 horseNameSheet22 = targetSheet.Cells(x, 22).value ' Assuming the horse name is in the 22nd column of Sheet2
  307.                
  308.                 ' Remove the region letters from the horse name in Sheet2
  309.                Dim regionPos2 As Integer
  310.                 regionPos2 = InStr(horseNameSheet22, "(")
  311.                 If regionPos2 > 0 Then
  312.                     horseNameSheet22 = Trim(left(horseNameSheet22, regionPos2 - 1))
  313.                 End If
  314.                
  315.                 ' Compare the horse names
  316.                If StrComp(horseNameSheet22, horseNameValue, vbTextCompare) = 0 Then
  317.                     Dim listItem2 As MSComctlLib.listItem
  318.                     Set listItem2 = ListView2.ListItems.Add(, , targetSheet.Cells(x, 1).value) ' Assuming the data you want to display is in the first column of Sheet2
  319.                    
  320.                     ' Call the subroutine to add subitems
  321.                    AddListViewSubItems listItem2, targetSheet, x
  322.                    
  323.                     matchFound = True ' Set the flag to indicate a match was found
  324.                End If
  325.             Next x
  326.         Next horseNameKey
  327.     End If
  328.    
  329.     ' Check if any matching data was found for the horse name(s)
  330.    If Not matchFound Then
  331.         MsgBox "No matching data found for horse name: " & horseName
  332.     End If
  333.    
  334.     PopulateComboBox
  335.    
  336. End Sub
  337.  
  338. Private Sub AddListViewSubItems(ByVal listItem As MSComctlLib.listItem, ByVal targetSheet As Worksheet, ByVal i As Long)
  339.     ' Add subitems to the ListView2
  340.  
  341.     listItem.SubItems(1) = targetSheet.Cells(i, 22).value ' Column 1
  342.    listItem.SubItems(2) = targetSheet.Cells(i, 3).value ' Column 2
  343.    listItem.SubItems(3) = targetSheet.Cells(i, 5).value ' Column 3
  344.    listItem.SubItems(4) = targetSheet.Cells(i, 13).value ' Column 4
  345.    listItem.SubItems(5) = targetSheet.Cells(i, 15).value ' Column 5
  346.  
  347.     Dim unformattedTime As String
  348.     unformattedTime = targetSheet.Cells(i, 27).Text ' Assuming the time value is stored as text in the cell
  349.  
  350.     ' Assign the unformatted time to the SubItems property
  351.    listItem.SubItems(6) = unformattedTime ' Column 7
  352.  
  353.     listItem.SubItems(7) = targetSheet.Cells(i, 18).value ' Column 8
  354.    listItem.SubItems(8) = targetSheet.Cells(i, 16).value ' Column 9
  355.    listItem.SubItems(9) = targetSheet.Cells(i, 21).value ' Column 10
  356.    listItem.SubItems(10) = targetSheet.Cells(i, 7).value ' Column 12
  357.    listItem.SubItems(11) = targetSheet.Cells(i, 25).value ' Column 13
  358.    listItem.SubItems(12) = targetSheet.Cells(i, 33).value ' Column 14
  359.    listItem.SubItems(13) = targetSheet.Cells(i, 34).value ' Column 15
  360.    listItem.SubItems(14) = targetSheet.Cells(i, 26).value ' Column 16
  361.    listItem.SubItems(15) = targetSheet.Cells(i, 19).value ' Column 17
  362.    listItem.SubItems(16) = targetSheet.Cells(i, 17).value ' Column 18
  363.    listItem.SubItems(17) = targetSheet.Cells(i, 30).value ' Column 19
  364.    listItem.SubItems(18) = targetSheet.Cells(i, 32).value ' Column 20
  365.    listItem.SubItems(19) = targetSheet.Cells(i, 39).value ' Column 3
  366.    ' Add more subitems as needed
  367.    
  368.    
  369.    
  370. End Sub
  371.  
  372.  
  373. Private Sub CreateListView1ColumnHeaders()
  374.  
  375.     ' Add column headers
  376.    ListView1.ColumnHeaders.Clear
  377.     ListView1.ColumnHeaders.Add , , "Horse Name" ' Column 1
  378.    ListView1.ColumnHeaders.Add , , "Form" ' Column 2
  379.    ListView1.ColumnHeaders.Add , , "Age" ' Column 3
  380.    ListView1.ColumnHeaders.Add , , "HG" ' Column 4
  381.    ListView1.ColumnHeaders.Add , , "WGT" ' Column 5
  382.    ListView1.ColumnHeaders.Add , , "OR" ' Column 6
  383.    ListView1.ColumnHeaders.Add , , "RPR" ' Column 7
  384.    ListView1.ColumnHeaders.Add , , "TS" ' Column 8
  385.    ListView1.ColumnHeaders.Add , , "Draw" ' Column 9
  386.    ListView1.ColumnHeaders.Add , , "Jockey" ' Column 10
  387.    ListView1.ColumnHeaders.Add , , "Trainer" ' Column 11
  388.    ListView1.ColumnHeaders.Add , , "Comments" ' Column 12
  389.    ' Add more column headers as needed
  390.    
  391.     'Optional settings columns
  392.    ListView1.ColumnHeaders.Add , , "Sex" ' Column 13
  393.    ListView1.ColumnHeaders.Add , , "Dam" ' Column 14
  394.    ListView1.ColumnHeaders.Add , , "Sire" ' Column 15
  395.    ListView1.ColumnHeaders.Add , , "Owner" ' Column 16
  396.    ListView1.ColumnHeaders.Add , , "Spotlight" ' Column 17
  397.    
  398.     Me.ListView1.Gridlines = True
  399.  
  400. End Sub
  401.  
  402. Private Sub CreateListView2ColumnHeaders()
  403.    
  404.     ' Add column headers*******************************************************************************
  405.    ListView2.ColumnHeaders.Clear
  406.     ListView2.ColumnHeaders.Add , , "Date" ' Column 1
  407.    ListView2.ColumnHeaders.Add , , "Name" ' Column 2
  408.    ListView2.ColumnHeaders.Add , , "Course" ' Column 3
  409.    ListView2.ColumnHeaders.Add , , "Race Type" ' Column 4
  410.    ListView2.ColumnHeaders.Add , , "Distance" ' Column 5
  411.    ListView2.ColumnHeaders.Add , , "Going" ' Column 6
  412.    ListView2.ColumnHeaders.Add , , "Time" ' Column 7
  413.    ListView2.ColumnHeaders.Add , , "Position" ' Column 8
  414.    ListView2.ColumnHeaders.Add , , "Runners" ' Column 9
  415.    ListView2.ColumnHeaders.Add , , "BTN" ' Column 10
  416.    ListView2.ColumnHeaders.Add , , "Class" ' Column 11
  417.    ListView2.ColumnHeaders.Add , , "WGT" ' Column 12
  418.    ListView2.ColumnHeaders.Add , , "OR" ' Column 13
  419.    ListView2.ColumnHeaders.Add , , "RPR" ' Column 14
  420.    ListView2.ColumnHeaders.Add , , "HG" ' Column 15
  421.    ListView2.ColumnHeaders.Add , , "Draw" ' Column 16
  422.    ListView2.ColumnHeaders.Add , , "No." ' Column 17
  423.    ListView2.ColumnHeaders.Add , , "Jockey" ' Column 18
  424.    ListView2.ColumnHeaders.Add , , "Prize" ' Column 19
  425.    ListView2.ColumnHeaders.Add , , "Comments" ' Column 20
  426.    
  427.     Me.ListView1.Gridlines = True
  428. End Sub
  429. Private Sub UserForm_Initialize()
  430.     ' Import racecard CSV data into a new sheet
  431.    Dim newSheet As Worksheet
  432.     Set newSheet = Workbooks("RaceCardAnalyser.xlsm").Worksheets.Add
  433.     With newSheet.QueryTables.Add(Connection:= _
  434.         "TEXT;D:\Racecard Analysis Project\Racecards\racecards.csv", Destination:=newSheet.Range("A1"))
  435.         .TextFileCommaDelimiter = True 'Set delimiter to comma
  436.        .TextFileParseType = xlDelimited
  437.         .Refresh
  438.     End With
  439.    
  440.     ' Import historical data CSV data into a new sheet
  441.    Dim newSheet2 As Worksheet
  442.     Set newSheet2 = Workbooks("RaceCardAnalyser.xlsm").Worksheets.Add
  443.     With newSheet2.QueryTables.Add(Connection:= _
  444.         "TEXT;D:\Racecard Analysis Project\Data\data.csv", Destination:=newSheet2.Range("A1"))
  445.         .TextFileCommaDelimiter = True 'Set delimiter to comma
  446.        .TextFileParseType = xlDelimited
  447.         .Refresh
  448.     End With
  449.    
  450.     CreateListView1ColumnHeaders
  451.     CreateListView2ColumnHeaders
  452.    
  453.     ' Store the name of the new racecard sheet
  454.    racecardSheetName = newSheet.Name
  455.    
  456.     ' Store the name of the new data sheet
  457.    dataSheetName = newSheet2.Name
  458.    
  459.     ' Create dictionary to store racecourses and times
  460.    Dim raceData As Object
  461.     Set raceData = CreateObject("Scripting.Dictionary")
  462.    
  463.     ' Loop through all rows of data
  464.    Dim currRow As Long
  465.     For currRow = 2 To newSheet.Cells(newSheet.Rows.Count, "A").End(xlUp).Row
  466.         ' Get current race course and race time AND horse name
  467.        Dim raceCourse As String
  468.         Dim raceTime As String
  469.         Dim horseName As String
  470.        
  471.         raceCourse = newSheet.Cells(currRow, 3).value
  472.         raceTime = Format(newSheet.Cells(currRow, 2).value, "h:mm")
  473.         horseName = newSheet.Cells(currRow, 12).value
  474.        
  475.         ' Add race course and race time to dictionary AND horse name
  476.        If Not raceData.Exists(raceCourse) Then
  477.             raceData.Add raceCourse, New Collection
  478.         End If
  479.        
  480.         ' Add race time to collection if it doesn't already exist
  481.        Dim raceTimeCheck As Collection
  482.         Set raceTimeCheck = raceData(raceCourse)
  483.         Dim found As Boolean
  484.         found = False
  485.         Dim i As Long
  486.         For i = 1 To raceTimeCheck.Count
  487.             If raceTimeCheck(i) = raceTime Then
  488.                 found = True
  489.                 Exit For
  490.             ElseIf raceTimeCheck(i) > raceTime Then
  491.                 raceTimeCheck.Add raceTime, Before:=i
  492.                 found = True
  493.                 Exit For
  494.             End If
  495.         Next i
  496.         If Not found Then
  497.             raceTimeCheck.Add raceTime
  498.         End If
  499.        
  500.     Next currRow
  501.    
  502.     ' Populate TreeView with data from dictionary
  503.    Dim raceCourses As Variant
  504.     For Each raceCourses In raceData
  505.         ' Add parent node for race course
  506.        Dim currNode As Node
  507.         Set currNode = TreeView1.Nodes.Add(, , raceCourses, raceCourses)
  508.         currNode.Tag = raceCourses
  509.        
  510.         ' Add child nodes for race times
  511.        Dim raceTimes As Variant
  512.         For Each raceTimes In raceData(raceCourses)
  513.             Set currNode = TreeView1.Nodes.Add(raceCourses, tvwChild, , raceTimes)
  514.             currNode.Tag = raceTimes
  515.         Next raceTimes
  516.     Next raceCourses
  517.    
  518.     ' Clean up
  519.    Set newSheet = Nothing
  520.     Set raceData = Nothing
  521.    
  522. End Sub
  523.  
  524. Private Sub UserForm_Terminate()
  525.  
  526.     ' NOTES: Remove the sheet created when the form was initialized
  527.    Application.DisplayAlerts = False 'Suppress alert message
  528.    Workbooks("RaceCardAnalyser.xlsm").Sheets(racecardSheetName).Delete
  529.    
  530.     Workbooks("RaceCardAnalyser.xlsm").Sheets(dataSheetName).Delete
  531.     Application.DisplayAlerts = True
  532.    
  533. End Sub
  534.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement