title: Excel formula to return a value from a range where conditional statements are true
body: <p>I've searched for an answer for this for awhile now but haven't had any luck. It's a bit difficult to put into words, so please let me know if anything's unclear.</p>
  
  <p>What I want is a way to perform conditional statements on two columns. When both conditions are true, I want to return the value from a third column that is in the same row as where these conditions were met.  So if the conditions are true in D5 and C5, I want to return the value from Q5 into the cell with the formula.  The conditional statements are easy enough but I haven't figured out the last step yet.</p>
  
  <p>If I use the following formula, I get 1 in the cell with the formula, which is right.</p>
  
  <pre><code>=IF(AND('Stata Output'!D2:D6='Backcheck schedule and results'!C2, 'Stata Output'!C2:C6=1),1,0)
  </code></pre>
  
  <p>However, replacing 1 in the formula with the range of cells that I want to pull the value from gives me a zero every time, which I know is wrong.  For this latter formula I'm using:</p>
  
  <pre><code>=IF(AND('Stata Output'!D2:D6='Backcheck schedule and results'!C2, 'Stata Output'!C2:C6=1),'Stata Output'!Q2:Q5,0)
  </code></pre>
  
  <p>Any ideas on where I'm messing up?
  Thanks!</p>