title: (VBA) Countif can't look in other sheet and bring answer back to original sheet
body: <p>I have an excel file with an unknown end range (which changes every time) and I want to know the amount of rows that the specific word comes back in that data table.</p>
  
  <p>It is just one column, and I have tried so many different methods but I still do not know the solution to it.</p>
  
  <p>This is the VBA code:</p>
  
  <pre><code>Sub count_cookies()
  
  lastrow = Worksheets("table").Cells(Rows.Count, 1).End(xlUp).Row
  Worksheets("table").Cells(6, 2) = WorksheetFunction.CountIf(Range("data!A2:A" &amp; lastrow), "* cookies *")
  End Sub
  </code></pre>
  
  <p>So I want the amount counted from sheet "data" to sheet "table", but what am I doing wrong?</p>
  
  <p>EDIT: I got a question, I have filtered data, but countif still counts all of the data, how can I count only the filtered data? IS there a different formula for this?</p>