View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach[_2_] Otto Moehrbach[_2_] is offline
external usenet poster
 
Posts: 1,071
Default count array for top three entries and return their number

Rich
I assumed you have only one row of data and it's in row 1 starting in
A1. This macro will produce a message box telling you the winner and how
many votes for that winner. Post back if you need more or if my assumptions
are wrong. HTH Otto
Sub GetBest()
Dim rRngRow1 As Range, i As Range
Dim HowMany As Long, What As Long
HowMany = 0
Set rRngRow1 = Range("A1", Cells(1, Columns.Count).End(xlToLeft))
For Each i In rRngRow1
If Application.CountIf(rRngRow1, i.Value) HowMany Then
HowMany = Application.CountIf(rRngRow1, i.Value)
What = i.Value
End If
Next i
MsgBox "Car number: " & What & Chr(13) & _
"How many: " & HowMany
End Sub
"Rich DeVito" wrote in message
...
I am trying to solve a scoring problem for a car show.

In a spread sheet we will have entry number of cars running across columns
that represent individual 1st place choices. Without filtering and
resorting
the data (no time at the car show) I need to dynamically determine the top
three entires and return the number of times they show up. I.E if these
are
the car entry numbers in their respective columns.

1 2 1 3 2 4 2 4 1 1 1 4 2

Should return
1 5
2 4
4 3
I don't even need the second number (number of votes, but we probably need
it to verify the formula is working).

Thanks!!