Find value (time) in a range and apply a condition

Simona

New Member
Joined
Aug 9, 2010
Messages
13
Hi,
I’m new to the board and I need some help.
I have 3 columns in Excel with the “Train number”, “Route” and “Time of departure” and I need to allocate the trains (4th column) using a list of meals according to the time of departure:
<table class="MsoNormalTable" style="width: 314pt; margin-left: 4.65pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0" width="419"> <tbody><tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> Route<o:p></o:p>
</td> <td colspan="2" style="width: 114.4pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="153" nowrap="nowrap">
Time Range<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> Meal<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> ALL <o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
00:00:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
09:29:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> BKF<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> ALL <o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
09:30:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
10:59:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> BKF+<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> ALL<o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
11:00:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
13:59:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> DTM<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> LISBON<o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
14:00:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
16:29:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> ALM<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> MADRID<o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
14:00:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
17:29:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> ALM<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> LISBON<o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
16:30:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
23:59:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> DIN<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> <tr style="height: 15pt;"> <td style="width: 107.1pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="143"> MADRID<o:p></o:p>
</td> <td style="width: 49.6pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
17:30:00<o:p></o:p>
</td> <td style="width: 64.8pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="86" nowrap="nowrap">
23:59:00<o:p></o:p>
</td> <td style="width: 69.85pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="93" nowrap="nowrap"> DIN<o:p></o:p>
</td> <td style="width: 22.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="30" nowrap="nowrap">
</td> </tr> </tbody></table> <o:p> </o:p>
Question 1: which formula should I use in order to return the meal for a train that, for example, departures at 9:54 as I have only the time ranges?
Question 2: solved the problem above, how can I make it work including the route (as you can see on the table the time range for the meals changes according to the route).
Thank you for your help!
NB: Better if not VBA
Simona
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

BobUmlas

Well-known Member
Joined
Mar 14, 2002
Messages
1,170
In your example, if the word "Route" is in A1, and you want to get the info from a time entered in F3, for example:
Q1: =VLOOKUP(F3,B2:D10,3)
Q2: =LOOKUP(F3,B2:B10,A2:A10)

HTH
 

Simona

New Member
Joined
Aug 9, 2010
Messages
13
Great!!!
in the Q1 I was always using the criteria "False" at the end of the vlookup formula which returns only exactly matches! Take it off and it will work perfectly with ranges.
For the second question the lookup formula is not enough but I used a nested "if" and now it's working nice!!!
Many thanks!
 
Last edited:

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,751
Messages
5,513,184
Members
408,940
Latest member
lbarraclough

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top