View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Issue with Ranking

Sub a_grand_staff()
iC = 1
cString = Cells(1, "B").Value
For iA = 2 To 5
If Cells(iA, "A").Value = Cells(iA - 1, "A").Value Then
cString = cString & " " & Cells(iA, "B").Value
Else
Cells(iC, "C").Value = cString
iC = iC + 1
cString = Cells(iA, "B").Value
End If
Next

If cString < "" Then
Cells(iC, "C").Value = cString
End If

End Sub

This little macro takes the first five entries in column A and moves the
names in column B to column C. If, however there are duplicate entries in
column A, the names in B are concatenated prior to being placed in column C.



Macros are very easy to install and use:

1. CNTRL-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary's Student
gsnu200705


" wrote:

I have a simple table, two columns A and B. In B1:B40 I have a list of
names, in A1:A40 are a list of numbers sorted from highest to lowest.
Ultimately what I'm trying to do is to get a ranking of the top 5
scores but, when there is a tie (duplicates in A) to take the names in
B next to the duplicate scores and Concatenate them in C. I've tried
using Rank, Vlookup, using Excel's FILTER and none of them work for
what I'm trying to do. My thought is to try to find a function that
will look through the numbers in A and when it finds duplicates
concatenate the matching names in a cell in C but as Vlookup only
returns one result it isn't working. Anyone have any ideas?