title: How do I get my formula to always reference to the last sheet?
body: <p>I currently have 2 worksheets in my excel file.</p>
  
  <p>The first sheet is known as the Summary page, which displays an summary result of the second sheet.</p>
  
  <p>The second sheet is known as the raw data. An example would be a column named Fruits.</p>
  
  <pre><code>Apple
  Apple
  Apple
  Banana
  Banana
  Pear
  </code></pre>
  
  <p>In the first sheet, I would have a formula that counts the number of time the respective fruits appear and the result will be displayed in different cells.</p>
  
  <pre><code>=COUNTIF(Fruits!A2:A7,"Apple")
  =COUNTIF(Fruits!A2:A7,"Banana")
  </code></pre>
  
  <p>What I wanna do is, is it possible for me to program the formula such that everytime I add a new sheet of raw data (3rd sheet), the statistics on the first sheet is able to reference to the latest sheet to get the information. </p>
  
  <p>(Assuming that the positioning of the data and all are the same as the second sheet.)</p>
  
  <p>What I have done so far is to come out with a function <code>GETLASTWSNAME()</code> which is able to always retrieve the name of the last worksheet. but it seems kinda impossible for me to nest the function within the countif formula itself.</p>
  
  <pre><code>=COUNTIF((GETLASTWSNAME())!A2:A7,"Apple)
  </code></pre>
  
  <p>The above formula is how i want my formula to work, but sadly excel does not allow me to do that.</p>
  
  <p>Any comments would be appreciated. Thanks!</p>