title: VBA - Get index of nth largest value in an array
body: <p>I want to find the index of the nth largest value in an array. I can do the following but it runs into trouble when 2 values are equal.</p>
  
  <pre><code>fltArr(0)=31
  fltArr(1)=15
  fltArr(2)=31
  fltArr(3)=52
  
  For i = 0 To UBound(fltArr)
      If fltArr(i) = Application.WorksheetFunction.Large(fltArr, n) Then
          result = i
      End If
  Next
  </code></pre>
  
  <blockquote>
    <p>n=1 ---> 3<br>
      n=2 ---> 2 (but I want this to be 0)<br>
      n=3 ---> 2<br>
      n=4  ---> 1</p>
  </blockquote>