title: Can Vlookup return a formula in excel?
body: <p>I am trying to use the <code>VLOOKUP</code> function in excel to return a formula. I've found plenty here on SO about using <code>VLOOKUP</code> but have a slightly different question.</p>
  
  <p>I am trying to get the week's average temperature (from column B) before a specified day (in column C) that can be found in column A.</p>
  
  <p>Put more simply:</p>
  
  <p>If date in <strong>cell</strong> C2 exists in <strong>column</strong> A, return <strong>average from range in column</strong> B.</p>
  
  <p>So far this is the closest I've got (thanks to other QAs on SO):</p>
  
  <pre><code>=VLOOKUP(C2, A1:B660, AVERAGE(B124:B130), FALSE)
  </code></pre>
  
  <p>However using the <code>AVERAGE</code> function in place of column number (which would usually be the argument used) does not seem to work.</p>
  
  <p>I've attached a very simplified picture of my data:</p>
  
  <p><img src="https://i.stack.imgur.com/DXFvy.png" alt="Data"></p>
  
  <p>If <code>VLOOKUP</code> is the wrong function to handle this what would be a better approach?
  I'm running Excel 15.32 on a Mac.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p><strong>Dummy data:
  <a href="https://www.dropbox.com/s/rblk943k2zf71tw/dummy%20data.xlsx?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/rblk943k2zf71tw/dummy%20data.xlsx?dl=0</a></strong></p>