title: finding minimum positive value (greater than 0) in an array in VBA
body: <p>I have an array (AlphaVector) with the following values:</p>
  
  <pre><code>-0.2
  -0.7
  0
  0.4
  0.3
  0.1
  </code></pre>
  
  <p>I want to pick the positive values from the above array and place it in another array named Alpha so that I can pick the minimum positive value from Alpha. My goal is to get the value 0.1 from the above array.
  Here's the code I have so far. Alpha gets populated ok as the Msgbox indicates the correct values, but the return value I am getting is 0 instead of 0.1.</p>
  
  <pre><code>Function FindMin(AlphaVector)
  Dim iCount As Long
  Dim N As Integer, i As Integer
  N = AlphaVector.Cells.Count
  Dim Alpha() As Double
  ReDim Alpha(N) As Double
  For i = 1 To N
      If AlphaVector(i) &gt; 0 Then
          Alpha(i) = AlphaVector(i)
      Else
          Alpha(i) = 100000000000#
      End If
      MsgBox ("Alpha(i)= " &amp; Alpha(i))
      MsgBox ("AlphaVector(i)= " &amp; AlphaVector(i))
  Next i
  FindMin = WorksheetFunction.Min(Alpha)
  End Function
  </code></pre>
  
  <p>Can you please tell me how to fix it? Also, if there is a more efficient way to write it, perhaps without introducing Alpha, please let me know. Thanks.</p>