Advertisement
Brovashift

Untitled

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