Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Ranking 'off sheet'

TIA for your hel
I have a 1 dimension array loaded with numbers
I would like to load another array with the numerical ranks of the elements of the first array. Would like to assign 'true ranks' ie 2 numbers tied at 2nd place = 2.5. Also would like to steer clear of worksheetfunction.rank (to keep the process 'off sheet' in the interests of speeding up th process
Any suggestions wil be much appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Ranking 'off sheet'

David,

See the example code below for one way.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim myVal(1 To 10) As Integer
Dim myRank(1 To 10) As Double
Dim i As Integer
Dim j As Integer

'Populate a test array
For i = 1 To 3
myVal(i) = i
Next i
For i = 4 To 10
myVal(i) = 11 - i
Next i

'Do the ranking
For i = LBound(myVal) To UBound(myVal)
myRank(i) = 1
For j = LBound(myVal) To UBound(myVal)
If i < j Then
If myVal(i) < myVal(j) Then
myRank(i) = myRank(i) + 1
ElseIf myVal(i) = myVal(j) Then
myRank(i) = myRank(i) + 0.5
End If
End If
Next j
Next i

'Show the values and rank results
Dim msg As String
msg = ""
For i = 1 To 10
msg = msg & myVal(i) & ": " & myRank(i) & Chr(10)
Next i

MsgBox msg

End Sub



"David" wrote in message
...
TIA for your help
I have a 1 dimension array loaded with numbers.
I would like to load another array with the numerical ranks of the

elements of the first array. Would like to assign 'true ranks' ie 2 numbers
tied at 2nd place = 2.5. Also would like to steer clear of
worksheetfunction.rank (to keep the process 'off sheet' in the interests of
speeding up th process)
Any suggestions wil be much appreciated



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ranking from one sheet to another casdaq Excel Worksheet Functions 0 May 11th 10 12:25 AM
top ten ranking liem Excel Discussion (Misc queries) 0 March 25th 10 01:12 AM
Ranking Question Listing Same Sheet! Killer Excel Discussion (Misc queries) 3 June 7th 07 02:12 AM
Ranking Curtis Excel Worksheet Functions 5 May 14th 06 03:59 AM
Ranking Thrava Excel Discussion (Misc queries) 6 February 15th 05 10:49 AM


All times are GMT +1. The time now is 08:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"