title: Excel - Recursive VLookup
body: <p>I recently came to know about Ctrl+Shift+Enter array formulas of Excel and currently still learning them. Coming to my problem,</p>
  
  <pre><code>SheetA:
  Product        Code
  S1             19875
  S2             19834
  S1             13575
  S1             35675
  S2             47875   
  
  
  
  SheetB:
  Code           Indent
  19875          40  
  19834          15
  13575          22
  35675          25
  47875          20
  </code></pre>
  
  <p>I need to do Sum of all Indents of a given Product name.</p>
  
  <p>Eg: I need S1's Total Indent,</p>
  
  <ul>
  <li>Vlookup on SheetA, Get the Code 19875</li>
  <li>Perform a vlookup on SheetB, Get the Indent of 40 </li>
  <li>Next Vlookup on Sheet A, Get the code 13575 </li>
  <li>Use 13575 to Vlookup on SheetB, Get Indent of 22</li>
  <li>Next Vlookup on Sheet A, Get the code 35675</li>
  <li>Use 35675 to Vlookup on SheetB, get indent of 25 </li>
  <li>Sum of 40+22+25, Return 87</li>
  </ul>
  
  <p>I can achieve this through VBA, but I'm wondering if this is possible within excel functions using CSE/Array formulas.</p>
  
  <p>Edit:</p>
  
  <p>I don't have values in Sheet2 in the same order of Sheet1.. They are completely random. My SheetB will be something randomly like following:</p>
  
  <pre><code>SheetB:
  Code           Indent
  19834          40  
  19875          15
  47875          22
  13575          25
  35675          20
  </code></pre>