Here is an interesting scenario.
Let’s say you are looking at a time, like 9:42 AM and want to know which 15 minute slot it fits into. The answer is 9:30 – 9:45. But how would you get this answer thru Excel formulas?

Excel formula to find slot from time:
Assuming A1 contains the input time, here is one formula that tells you the time slot.
=TEXT(TIME(HOUR(A1),INT(MINUTE(A1)/15)*15,0),”hh:mm”)&” – “&TEXT(TIME(HOUR(A1),(INT(MINUTE(A1)/15)+1)*15,0),”hh:mm”)
Whoa!, that’s long. Let’s examine the inner workings of this beast.
Logic: We need to figure out both lower & upper boundaries of fifteen minute slot for time in A1. The lower boundary is quotient of A1/15 minutes multiplied by 15. For example, 09:42’s lower boundary is 09:30. The upper boundary is lower boundary + 15 minutes.
Implementation:
INT(MINUTE(A1)/15) * 15 portion: this part of the formula tells us the minutes. We extract the minute part of A1 (using MINUTE(A1)) and divide it with 15. We then take only the integer portion of this division and multiply that with 15 again. This gives us the minute portion of lower boundary of our time slot.
TIME(HOUR(A1), INT(..)*15, 0) portion: We then create a time value using the TIME formula by using the same hour as A1, minutes from lower boundary calculation using the INT(…)* 15 and 0 as seconds.
TEXT(TIME(…), “hh:mm”) portion: This will convert the time value to text formatted as hh:mm.
So far we have constructed the lower boundary of time slot. The upper boundary part of the formula is similar with one minor change. Go figure it out.
How to find 1 hour time slot?
Let’s say you want to find the time slot on hourly basis, then what?
Below formula does the job.
=HOUR(A1)&”:00 – ” & (HOUR(A1)+1) & “:00”
What if your time slots are not uniformly spaced?
The above approaches work fine as long as your time slots are uniformly spaced (ie 15 minutes, 1 hour, 4 hours or 8 hour apart). What if you have a unique set up? Something like this:

In that case you can use the range lookup method.
Related: read about pricing tier lookup too.
So there you go. For more information about working with date & time values in Excel, check out below material.
- Convert fractional time to proper time in Excel
- Find last day of any month with this simple trick
- 42 tips for Excel time travelers – Must read!!!
- Check if two dates are in same month
- More formulas & tutorials on Excel date & time
A challenge for you:
How would you write the 15 minute time slot formula? Can you figure out other ways to calculate it? Please share your formulas in the comments section. Your time starts now!














13 Responses to “Data Validation using an Unsorted column with Duplicate Entries as a Source List”
Pivot Table will involve manual intervention; hence I prefer to use the 'countif remove duplicate trick' along with 'text sorting formula trick; then using the offset with len to name the final range for validation.
if using the pivot table, set the sort to Ascending, so the list in the validation cell comes back alphabetically.
Hui: Brillant neat idea.
Vipul: I am intrigued by what you are saying. Please is it possible to show us how it can be done, because as u said Hui's method requires user intervention.
Thks to PHD and all
K
Table names dont work directly inside Data validation.
You will have to define a name and point it to the table name and then use the name inside validation
Eg MyClient : Refers to :=Table1[Client]
And then in the list validation say = MyClient
Kieranz,
Pls download the sample here http://cid-e98339d969073094.skydrive.live.com/self.aspx/.Public/data-validation-unsorted-list-example.xls
Off course there are many other ways of doing the same and integrating the formulae in multiple columns into one.
Pls refer to column FGHI in that file. Cell G4 is where my validation is.
Vipul:
Many thks, will study it latter.
Rgds
K
[...] to chandoo for the idea of getting unique list using Pivot tables. What we do is that create a pivot table [...]
@Vipul:
Thanks, that was awesome! 🙂
@Playercharlie Happy to hear that 🙂
Great contribution, Hui. Solved a problem of many years!
Thanks to you, A LOT
Hi Hui,
Greeting
hope you are doing well.
I'm interested to send you a private vba excel file which i need to show detail of pivot in new workbook instead of showing in same workbook as new sheet.
Please contact me on muhammed.ye@gmail.com
Best Regards