title: How to use index match formula that automatically expands in Google Sheets
body: <p>In Google Sheets I am using a filter function to pull in Names into column A and a Timestamp into column B. Every time a second occurrence of the name shows up into columns A &amp; B of the list I want column C next to the prior occurrence to reference the new timestamp. In column D I will then calculate the difference from the names timestamp and the next occurrence of that same name.</p>
  
  <p>Currently I am using the following formula:</p>
  
  <pre><code>=IFERROR(INDEX(B3:B,MATCH(A2,A3:A,0)))
  </code></pre>
  
  <p>If I drag this formula down it does what I need it to do, but due to how many rows are being added to the first two columns, rows are being added to the bottom of the sheet due to the filter and the formulas keep needing to be dragged down. The durations in column D are being calculated with the following formula, that automatically arrays the results and automatically expands with the filter results:</p>
  
  <pre><code>=IFERROR(ARRAYFORMULA(IF(C2:C="","",C2:C-B2:B)))
  </code></pre>
  
  <p>I would like my index match formula to do the same, but it seems I cannot use the index formula with an arrayformula.</p>
  
  <p>I attempted to achieve this by using a vlookup combined with an offset for the range. The first row is giving me the result I want, but all the subsequent rows are not referencing the offset range, probably because the offset isn't changing with each new array result here is that attempt:</p>
  
  <pre><code>=IFERROR(ARRAYFORMULA(VLOOKUP(A2:A,OFFSET(A2:B,1,0),2,FALSE)))
  </code></pre>
  
  <p>Any ideas how this could be accomplished by placing a formula in one  cell, or would this have to be accomplished with a script?</p>
  
  <p>I have added an example spreadsheet of the current method <a href="https://docs.google.com/spreadsheets/d/1okJ-ozcWUo_Noc5jlYujTsMRQ3wX60y3tkAvh9lDA0o/edit#gid=0" rel="nofollow">HERE</a></p>
  
  <p>Thanks in advance for any help.</p>