title: How to create a range relative to current cell in google spreadsheet
body: <p>I have put the same question/requirement again but with a clear and small example to convey the intention correctly.</p>
  
  <p>I have one column with dates, but not every row necessarily has it. The adjacent column should have the number of days occurred since that date. What should be the formula for that. I have tried several things, but still cannot get it correct. Below is an example.</p>
  
  <pre><code>       A           B         C              D
  1      S.no.     Task        Date        Number of days
  2       1        task1       10may16        6
  3       1.1      task2                      6
  4       1.2      task3                      6
  5       2        task4       12may16        4
  6       2.1      task5                      4
  7       3        task6       13may16        3
  </code></pre>
  
  <p>Here how to get the correct values in column 'D', especially in D3, D4 and D6? For these cells, it takes the reference date from previous filled row of column 'B'. The current date is assumed to be 16th May 2016.</p>
  
  <h2>old question below</h2>
  
  <p>I am trying to find out a non-empty cell in a column based on another cell in a different column. For example, which is the last non-empty cell in column B1:Bx, where 'x' is the row number in column E where I use this value, say 24, when I am trying to use that value in E24. </p>
  
  <p>In my case the column B contains dates and 'E' contains the difference between current date and the date in column 'B'. Sometimes the corresponding column doesn't have a date, in which case, I would go up to find last date in that column and find difference.</p>
  
  <p>I have been looking up internet to find out ways to do this but hasn't found anything yet. One way that might be close to what I want is given at <a href="https://stackoverflow.com/questions/8116043/get-the-last-non-empty-cell-in-a-column-in-google-sheets">Get the last non-empty cell in a column in Google Sheets</a>. But this also doesn't work for me. The difference is that I don't search complete column but only till the row where the value is required in 'E' column. This is where I am not able to adapt the given formula. The one that I tried, given below, results in <code>#Error!</code>.</p>
  
  <pre><code>=INDEX(FILTER( "B2:B"&amp;ROW()-1 , NOT( ISBLANK( "B2:B"&amp;ROW()-1 ) ) ) , ROWS( FILTER( "B1:B"ROW()-1 , NOT( ISBLANK( "B2:B"&amp;ROW()-1) ) ) ) )
  </code></pre>
  
  <p>So, I guess, I want to know the correct way of creating range based on current row value. The error most likely is in part <code>"B2:B"&amp;ROW()-1</code></p>