Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>Public Function TopTen(Club As String, Scores As Range) Dim i As Long Dim vaScores As Variant Dim bLady As Boolean Dim lCnt As Long Dim lTotal As Long vaScores = FilterOnClub(Scores.Value, Club) vaScores = SortOnScore(vaScores) For i = LBound(vaScores, 2) To UBound(vaScores, 2) If lCnt = 3 And Not bLady Then If vaScores(3, i) &lt;&gt; "Gent" Then lTotal = lTotal + vaScores(4, i) bLady = True lCnt = lCnt + 1 End If Else lTotal = lTotal + vaScores(4, i) lCnt = lCnt + 1 If vaScores(3, i) &lt;&gt; "Gent" Then bLady = True End If If lCnt = 4 Then Exit For Next i TopTen = lTotal End Function Private Function FilterOnClub(vaScores As Variant, sClub As String) As Variant Dim i As Long, j As Long Dim aTemp() As Variant For i = LBound(vaScores, 1) To UBound(vaScores, 1) If vaScores(i, 2) = sClub Then j = j + 1 ReDim Preserve aTemp(1 To 4, 1 To j) aTemp(1, j) = vaScores(i, 1) aTemp(2, j) = vaScores(i, 2) aTemp(3, j) = vaScores(i, 3) aTemp(4, j) = vaScores(i, 4) End If Next i FilterOnClub = aTemp End Function Private Function SortOnScore(vaScores As Variant) As Variant Dim i As Long, j As Long, k As Long Dim aTemp(1 To 4) As Variant For i = 1 To UBound(vaScores, 2) - 1 For j = i To UBound(vaScores, 2) If vaScores(4, i) &lt; vaScores(4, j) Then For k = 1 To 4 aTemp(k) = vaScores(k, j) vaScores(k, j) = vaScores(k, i) vaScores(k, i) = aTemp(k) Next k End If Next j Next i SortOnScore = vaScores End Function </code></pre> <p>Use as <code>=TopTen(H2,$B$2:$E$30)</code> where <code>H2</code> contains the club letter.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload