title: Creating a VBA formula using CountIF
body: <p>I am creating a formula to count based upon 2 conditions.  My logic is wrong - again.  </p>
  
  <p>When I (manually) enter enter code the summation formula (COUNTIFS) into correct cell itself, it sums correctly:</p>
  
  <pre><code>COUNTIFS(E4:E1362,"Requirement",S4:S1362, "&lt;&gt;4")
  </code></pre>
  
  <p>When I execute the following code line, I do not get any errors, but instead, all the sums are zero.</p>
  
  <pre><code>Range("G" &amp; Start(groups) - 1).Formula = "=COUNTIFS(E" &amp; Start(groups) &amp; ":E" &amp; Finish(groups) &amp; "," &amp; "Requirement" &amp; ",S" &amp; Start(groups) &amp; ":S" &amp; Finish(groups) &amp; "," &amp; Chr(34) &amp; "&lt;&gt;4" &amp; Chr(34) &amp; ")"
  </code></pre>
  
  <p>I realized that the COUNTIFS was comparing the value in column S to the string "&lt;>4".  And none of the cells contain that string.  This is why all my values were zero.  I do not want the comparison to be against that string.  I want the comparison to be column S value NOT equal to 4.  </p>
  
  <p>So, I changed the line to (and variations to get it to work):</p>
  
  <pre><code>Range("G" &amp; Start(groups) - 1).Formula = "=COUNTIFS(E" &amp; Start(groups) &amp; ":E" &amp; Finish(groups) &amp; "," &amp; "Requirement" &amp; ",S" &amp; Start(groups) &amp; ":S" &amp; Finish(groups) &amp; "," &amp; Chr(34) &amp; "&lt;&gt;" &amp; Chr(34) &amp; "4)"
  </code></pre>
  
  <p>So, I am at a loss.  (1) I manually enter the formula and it works.  (2) I build it in VBA, and it does not sum correctly.  (3) I look up how to do build the formula correctly, and I get errors time and time again.  It seems like the only way to get this to work is to keep the quotes within quotes, but I don't want to compare against the string.</p>
  
  <p>Does this make sense?  I'm not liking my worksheet anymore.  It is no longer any fun at all.  :(</p>
  
  <p>Thank you so much. </p>