Say I have the following table (A much smaller one than the one I actually have):
<tbody>
</tbody>
I want to go through the list and delete all other times except the top 3 for each country and the corresponding racer.
My idea was having a column with =COUNTIF() and therefore displaying:
<tbody>
</tbody>Therefore if <2 then ignore and skip this particular case.
I was thinking a way to skip between cases... I guess if you know the number of racers you can compare all their times and then rank the top 3 but I dont know how to do that.... I've had a dig at it but got nowhere - any advice on how/where to go would be v appreciated!
Thanks.
Code so far:
Japan | Time |
RacerA | 44 |
RacerB | 23 |
RacerC | 154 |
RacerD | 17 |
RacerE | 16 |
China | Time |
RacerA | 11 |
RacerB | 165 |
Romania | Time |
RacerA | 11 |
RacerB | 16 |
RacerC | 19 |
RacerD | 24 |
RacerE | 130 |
<tbody>
</tbody>
I want to go through the list and delete all other times except the top 3 for each country and the corresponding racer.
My idea was having a column with =COUNTIF() and therefore displaying:
5 |
2 |
5 |
<tbody>
</tbody>
I was thinking a way to skip between cases... I guess if you know the number of racers you can compare all their times and then rank the top 3 but I dont know how to do that.... I've had a dig at it but got nowhere - any advice on how/where to go would be v appreciated!
Thanks.
Code so far:
Code:
Private Sub fixIT()
Dim lr As Long
Dim impCell As Range
'refering to the countif column
impCell = Range("C1")
'refering to the Column that has all the time values.
lr = Range("B" & Rows.Count).End(xlUp).Row
Range("B1").Select
For j = 1 To lr
'If impCell.value < 3 then goto Line 1
'If ActiveCell.Value is not in top 3 then
ActiveCell.Delete shift:=xlUp
ActiveCell.Offset(0, -1).Delete shift:=xlUp
Line1:
Else
ActiveCell.Offset(1, 0).Select
End If
Next
End Sub