title: Excel 2007 Visual Basic: minimum values
body: <p>Here's sample sheet:</p>
  
  <p><strong>ColA, ColB, ColC</strong><br>
  A, 0.2, 10%<br>
  A, 0.3, 1%<br>
  A, 0.5, 6%<br>
  B, 0.4, 9%<br>
  B, 0.3, 8%<br>
  B, 1.2, 40%</p>
  
  <p>I have to find minimum value in <strong>ColB</strong> for specified value in <strong>ColA</strong>, then check if <strong>ColC</strong> in this row is greater than 15%. If so - return value of <strong>ColB</strong>. If not, find next minimum value and sum with previously found value, then again check if sum is greater than 15%, and so on.. Return last summed value from <strong>ColB</strong>.</p>
  
  <p>Example (for <strong>ColA</strong>="<strong>A</strong>"):<br>
  1. find minimum value in <strong>ColB</strong> (cell: B2, value 0.2)<br>
  2. check if value in <strong>ColC</strong> in this row (cell: C2, value 10%) is greater than 15% (not met!) sum with previously val = 0 + 10% = 10%<br>
  3. take next minimum value in <strong>ColB</strong> (cell: B3, value 0.3)<br>
  4. check >15% condition -> (cell: C3, value 1%) sum with previously val = 10% + 1% = 11% (still not met)<br>
  5. take next minimum value in <strong>ColB</strong> (cell: B4, value 0.5)<br>
  6. check >15% condition -> (cell: C4, value 6%) sum with previously val = 11% + 6% = 17% (condition met)<br>
  7. The last cell we summed was C4, so we return value from <strong>ColB</strong> in this row - <strong>0.5</strong></p>
  
  <p>(Answer for "B" is 0.4)</p>
  
  <p>I'd like to ask for any hints to solve this problem. Hope it's clear ;)</p>
  
  <p>Here's the prototype of my function<br>
  <code>Function foo(ColA As String) As Integer</code></p>