title: Lookup and calculation with mulitple criteria also based on a cell value
body: <p>I'm trying to create a spreadsheet that will allow me to quickly calculate the amount of time my trains were delayed on a daily basis.</p>
  
  <p>I need a formula that will check for all trains on a particular route after a planned departure time (written in a cell),check these trains actual arrival time and then display the earliest possible time I could have arrived at my destination.</p>
  
  <p><a href="http://i.stack.imgur.com/n6frW.png" rel="nofollow">spreadsheet image</a></p>
  
  <p>For example, in G4 I would like a formula that looks for all trains that depart after 7:49 (A4) and also match both of it's "From" and "To" (C4 &amp; D4). It would then need to check these trains corresponding  "actual arrival times" in column F and show the earliest possible train. So for row 4 this would be 9:36.</p>
  
  <p>Any help would be really appreciated as I have been messing around with this for over a day and have gotten nowhere! </p>
  
  <p>A link to the example is here - <a href="https://docs.google.com/spreadsheets/d/1eE8t4-_hKB6o5j3W57EHgKzsF9p1usm7nojerjmrDwY/edit#gid=0" rel="nofollow">https://docs.google.com/spreadsheets/d/1eE8t4-_hKB6o5j3W57EHgKzsF9p1usm7nojerjmrDwY/edit#gid=0</a></p>
  
  <p>Thanks
  Oli</p>