title: Count if function not working properly in vba
body: <p>I'm having some trouble getting my macro to use a countif funtion to display the frequency of scores in a given cell.  This is part of a larger macro that I am currently working on to generate a report out of a given set of exported data.  </p>
  
  <p>When I try to run the code, it returns all zeros in the cells I have specified even though there is data in there that matches my criteria.</p>
  
  <p>Please feel free if you like to critique this code as I am just starting out in programming and wanting to learn as much as possible.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Here is a copy of the code:</p>
  
  <pre><code>Dim i As Integer
  Dim ws_raw As Worksheet
  Dim ws_rpt As Worksheet
  
  Set ws_raw = Sheets("Raw Data")
  Set ws_rpt = Sheets("Report")
  
  If ws_raw.Range("H2") &lt;&gt; "" Then
  
      i = WorksheetFunction.CountIf(Range("S2:CCC2"), "5")
      ws_raw.Range("I2").Value = i
  
      i = WorksheetFunction.CountIf(Range("S2:CCC2"), "6")
      ws_raw.Range("J2").Value = i
  
      i = WorksheetFunction.CountIf(Range("S2:CCC2"), "7")
      ws_raw.Range("K2").Value = i
  
      i = WorksheetFunction.CountIf(Range("S2:CCC2"), "8")
      ws_raw.Range("L2").Value = i
  
  Else
  
  End If
  </code></pre>