title: How can I fix this Excel formula in ordert to exlude rows from calculation when two different columns has a specific value?
body: <p>I am not so into Excel and I am finding the following difficulty trying to adapt a pre-existing formula to a new requirement.</p>
  <p>Basically I have this original formula (workiong fine):</p>
  <pre><code>=SUMPRODUCT((D2:D7)*(B2:B7=&quot;BUY&quot;))/SUMPRODUCT((G2:G7)*(B2:B7=&quot;BUY&quot;))
  </code></pre>
  <p>This basically calculate an avarange price checking that the value of the B column is &quot;BUY&quot; (basically to exclude when the row is a SELL row). It works fine.</p>
  <p>Now I have to change the previous formula excluding also all the row having the H column having value different from &quot;CC&quot;. I have try in this way:</p>
  <pre><code>=SUMPRODUCT((D2:D7)*(B2:B7=&quot;BUY&quot; AND H2:H7=&quot;CC&quot;))/SUMPRODUCT((G2:G7)*(B2:B7=&quot;BUY&quot; AND H2:H7=&quot;CC&quot;))
  </code></pre>
  <p>Basically I tried to add an <strong>AND</strong> condition checking if the <strong>H</strong> column value is <strong>CC</strong>. But it is not working. It give me a syntax error when I try to insert this second version of my forumula.</p>
  <p>Why? What is wrong? What am I missing? How can I fix my formula?</p>