title: How to count the number of observations (in Excel)?
body: <p>I have two worksheets in an Excel file:</p>
  
  <p>companies</p>
  
  <pre><code>  A       B      C     D     E
  1 COMPANY SECTOR VAR_1 VAR_2 VAR_3
  2 Sony    Tech         2.40  no
  3 Ikea    Home   7     1.44  yes
  4 ING     Bank   5        0  yes
  5 BofA    Bank   0           no
  6 Google  Tech            0  yes
  7 Staples Home         5.24  no
  8 Trump   Ego    5     9.99  yes
  9 ABN     Bank         2.64  no
  </code></pre>
  
  <p>This sheet holds hundreds of <code>VAR</code>s for thousands of companies. There are many missing values (empty cell is missing value, <code>0</code> actually is an observed value). I need to know how many observations I have for each <code>VAR</code>. I need (1) an overall count of the number of observations and (2) the number of observations for companies that are in the banking sector. In the sheet below, (1) is in column <code>B</code>, (2) in column <code>C</code>:</p>
  
  <p>variables</p>
  
  <pre><code>   A       B     C
  1 VARIABLE TOTAL BANK
  2 VAR_1    4     2  
  3 VAR_2    7     2
  4
  5          Some random comment...
  6
  7 VAR_3    8     3
  </code></pre>
  
  <p>Let's take <code>VAR_1</code> as an example. Looking at the <code>companies</code> sheet, there are 4 observations for this variable (<code>7</code>, <code>5</code>, <code>0</code> and <code>5</code>). Looking solely at banks (<code>SECTOR == 'Bank')</code> there are 2 observed values (<code>5</code> for ING and <code>0</code> for BofA).</p>
  
  <p>It is possible that in the <code>variables</code> sheet, there are comments in between different variables (although never in in column <code>A</code>; this column holds either a variable name or is empty). Also, the <em>order</em> of variables might not be the same. So in <code>companies</code> could say</p>
  
  <pre><code>  ... GH     GI     GJ
  1     VAR_40 VAR_41 VAR_42
  </code></pre>
  
  <p>while in <code>variables</code> it says</p>
  
  <pre><code>    A
  ...
  60  VAR_40
  61  VAR_42
  62  VAR_41
  </code></pre>
  
  <p>My question is: what formula's can calculate the number of observations in <code>variables</code> columns <code>B</code> and <code>C</code>? Any help is greatly appreciated.</p>