title: Median array index in an array of 5 values
body: <p>I have an array of 5 numbers in Excel VBA.</p>
  
  <p>Each array index number is an x coordinate and the array value at each index is the Y coordinate/value. I'm trying to find the "median" x coordinate in the array based on the y values within the array.</p>
  
  <p>Example 1:</p>
  
  <pre><code>Array(1) = 1, Array(2) = 0, Array(3) = 1, Array(4) = 1, Array(5) = 2
  </code></pre>
  
  <p>I envisage the x coordinate median would be (after rounding) index 4 - are there functions in Excel would support determining this or perhaps some suggested code please?</p>
  
  <p>Example 2:</p>
  
  <pre><code>Array(1) = 7, Array(2) = 1, Array(3) = 4, Array(4) = 7, Array(5) = 1
  </code></pre>
  
  <p>I envisage the x coordinate median would be (after rounding) index 3?</p>
  
  <p>Example 3:</p>
  
  <pre><code>Array(1) = 1, Array(2) = 0, Array(3) = 0, Array(4) = 0, Array(5) = 6
  </code></pre>
  
  <p>I envisage the x coordinate median would be (after rounding) index 5?</p>
  
  <p>Example 4:</p>
  
  <pre><code>Array(1) = 5, Array(2) = 0, Array(3) = 7, Array(4) = 0, Array(5) = 6
  </code></pre>
  
  <p>I envisage the x coordinate median would be (after rounding) index 3?</p>
  
  <p>Thanks in advance!</p>