title: Hierarchical auto-numbering (with three levels) in Excel
body: <p>What if we have a three-level hierarchy and need to enumerate only "B"s (according to the pattern), but some "C-"s interfere with "B"s.</p>
  
  <p><strong>Problem</strong>: to get column <code>B</code> result from a given column <code>A</code>. </p>
  
  <pre><code>A+  
  B   1
  B   2
  С-  
  B   3
  A+  
  B   1
  С-  
  B   2
  A+  
  С-  
  B   1
  B   2
  B   3
  </code></pre>
  
  <p><strong>P.S.</strong> The task arose from the need to enumerate complex hierarchy in Excel.</p>
  
  <p>Imagine that <code>A</code> - level 1; <code>B</code> - level 2; <code>C</code> - level 3. (with some abuse of logic in the example above as <code>C-</code> in the pattern goes after <code>A</code>, which in practice is usually not the case).</p>
  
  <p>The simple case of two-level hierarchy is shown <a href="https://stackoverflow.com/questions/32313313/hierarchical-auto-numbering-in-excel">here</a>. </p>