title: VBA code for SUMIFS?
body: <p>I'm trying to write a custom function that will let me retrieve a cell from the first row in a range that meets x number of criteria. I imagine this would be very similar to the way SUMIFS works, just simpler in that it doesn't continue processing after the first match. </p>
  
  <p>Does anyone know code to reproduce the SUMIFS (excel 07) function in VBA?</p>
  
  <p>So, for example, if I have a table in excel like:</p>
  
  <pre><code>W X Y Z
  a b 6 1
  a b 7 2
  b b 7 3
  </code></pre>
  
  <p>I want to be able to write a function that will give me the value in column Z where columns W=a, X=b, Y>=7 (in other words the value 2).</p>
  
  <p>SUMIFS can approximately do this, assuming the record I want is unique and I'm looking to return a number. For my purposes though, those assumptions won't work.</p>