Dependent Lists for Start and End times

jock444

New Member
Joined
Feb 13, 2019
Messages
9
Hi, I'm creating an employee rota with Start and End times that are entered using drop down lists. I would like the End time list to change to only show times that are after the chosen Start time. For example:

Start Time ListEnd Time List
07:0007:00
08:0008:00
09:0009:00
10:0010:00
11:0011:00
etc.etc.

<tbody>
</tbody>

If 09:00 Start Time is chosen, only times from 10:00 onwards are shown for the End Time. I've been reading up on dependent lists but how to limit the second list to a certain range based on the option chosen in the first list? Any help or pointers would be greatly appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
In cell D2 put a drop down list with the range:
=$A$2:$A$18


In the Name Manager, create a name called "EndTime", in it refers to:
=INDIRECT("Sheet1!$B$" & MATCH(Sheet1!$D2,Sheet1!$A$1:$A$18,0) + 1 & ":$B$18")


In cell E2 put a drop down list with:
=EndTime


Check the file below
https://www.dropbox.com/s/sk6kp7a645g9jx4/time drop down list.xlsx?dl=0

Excel Workbook
ABCDE
1Start TimeEnd TimeStart TimeEnd Time
207:0007:0010:0012:00
308:0008:00
409:0009:00
510:0010:00
611:0011:00
712:0012:00
813:0013:00
914:0014:00
1015:0015:00
1116:0016:00
1217:0017:00
1318:0018:00
1419:0019:00
1520:0020:00
1621:0021:00
1722:0022:00
1823:0023:00
Sheet1
 
Upvote 0
That's awesome, thanks a lot Dante. Is there a way of clearing the End Time (blanking the E2 cell) after a Start Time is selected as that would make it absolutely perfect for our needs.
 
Upvote 0
Is there a way of clearing the End Time (blanking the E2 cell) after a Start Time is selected as that would make it absolutely perfect for our needs.



Only with a macro.
To insert te code, Right click the tab of the sheet you want this to work, select view code & paste the code below into the window that opens up.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("D2")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        Target.Offset(0, 1).Value = ""
    End If
End Sub
 
Upvote 0
Thanks Dante it works great, really appreciate your help. One final question, I've got other start and end times elsewhere on the sheet. What would be the best way of changing the macro so that it does the same thing for other cells I specify rather than just D2 (for example D2, D4 and G2)?
 
Upvote 0
Try:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("D2, D4, G2")) Is Nothing Then
        If Target.Count > 1 Then Exit Sub
        Target.Offset(0, 1).Value = ""
    End If
End Sub
 
Upvote 0
Thanks, works great. I've realised another issue with trying to have more than one start and end time drop down list on the same sheet. The INDIRECT statement to alter the end list is for one cell/list only (D2)

=INDIRECT("Sheet1!$B$" & MATCH(Sheet1!$D2,Sheet1!$A$1:$A$18,0) + 1 & ":$B$18")

Is there a way of changing this code to make it work for other cells I specify or would it need another solution like a macro?
 
Upvote 0
Only copy the pair of cells (D2 and E2) in another location on the sheet and cell "D2" is set automatically in the Indirect formula.
 
Upvote 0
Thanks Dante, it only seems to work when copying to the same column but I can live with that as I've found a way around it. Thanks again, you've been a great help.
 
Upvote 0
Use this formula:

In the Name Manager, create a name called "EndTime", in it refers to:
=INDIRECT("Sheet1!$B$" & MATCH(Sheet1!D2,Sheet1!$A$1:$A$18,0) + 1 & ":$B$18")
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top