title: Using CountIf in VBA with visible cells
body: <p>I am trying to use a <code>CountIf</code> function in vba on visible cells to count all the visible cells that are <code>yes</code>, there are 25 but I get the error </p>
  
  <blockquote>
    <p>Unable to get the <code>CountIf</code> property of the <code>WorksheetFunction</code> class</p>
  </blockquote>
  
  <p>and it highlights <code>returnCount</code>, not sure if there is also an error with <code>myrange</code>, any help would be much appreciated.</p>
  
  <pre><code>Set myrange = _
  Range("D4",Range("D4").End(xlDown)).SpecialCells(xlCellTypeVisible)
  
  returnCount = WorksheetFunction.CountIf(myrange, "yes")
  </code></pre>