title: Returning an Index of a Min value in Array Excel VBA
body: <p>I'm trying to find an index of the minimum value from sum(3) array. And it should be assigned to a variable <em>min</em>  </p>
  
  <p>min = <em>index of minimum value</em></p>
  
  <p>Should I sort the array first or is there any direct way of doing it?<br>
  Here is my code:  </p>
  
  <pre><code> `Sub Min_index()
          Dim Pt_array(3) As Single
          Pt_array(0) = 0
          Pt_array(1) = 12.3
          Pt_array(2) = 16.06
          Pt_array(3) = 20.11
  
          Dim Ad_E_array(3) As Single
          Dim Lo_E_array(3) As Single
          Dim Bs_temp As Single
  
          Dim i As Integer
          i = 0
          Do While i &lt; 4
              Bs_temp = BS
              Ad_E_array(i) = Ad_E    'defined in previous Sub
              Lo_E_array(i) = Lo_E    'defined in previous Sub
  
              If Bs_temp + Pt_array(i) - Qth &lt; BS_Maximum_limit Then
                  Bs_temp = Bs_temp + Pt_array(i) - Qth
                  Ad_E_array(i) = Ad_E_array(i) + 0
                  Lo_E_array(i) = Lo_E_array(i) + 0
                  Call function_decide(int_forecast_hour - 1, Bs_temp, Qth + 1, Lo_E_array(i), Ad_E_array(i))
              Else
                  Lo_E_array(i) = Pt_array(i) - Qth - (BS_Maximum_limit - Bs_temp)
                  Bs_temp = BS_Maximum_limit
                  Call function_decide(int_forecast_hour - 1, Bs_temp, Qth + 1, Lo_E_array(i), Ad_E_array(i))
              End If
          i = i + 1
          Loop
  
          Dim sum(3) As Single
          Dim min As Single
          i = 0
          Do While i &lt; 4
          sum(i) = Abs(Lo_E_array(i)) + Abs(Ad_E_array(i))
          i = i + 1
          Loop
    End Sub`  
  </code></pre>