Search code examples
excelcell-formatting

How do I format cells to display a time range instead of just the time?


I'm trying to create a schedule for myself, but I get confused by seeing the following:

8:00 AM
8:30 AM
9:00 AM
9:30 AM
10:00 AM
10:30 AM
11:00 AM
11:30 AM
12:00 PM

I can never remember whether I am looking at the right block, so I instead want to see this:

8:00 AM to 8:30 AM
8:30 AM to 9:00 AM
9:00 AM to 9:30 AM
9:30 AM to 10:00 AM

Is there an easy way to do this that doesn't involve me typing it into every cell? I want to be able to flash fill the rest of my table, if I can.

(Note: the below is a workaround where I just made a separate column, but it'd be nice if I could do it in one cell.)

Start        End
8:00 AM      8:30 AM
8:30 AM      9:00 AM
9:00 AM      9:30 AM
9:30 AM     10:00 AM
10:00 AM    10:30 AM
10:30 AM    11:00 AM
11:00 AM    11:30 AM
11:30 AM    12:00 PM
12:00 PM    12:30 PM

Solution

  • Use this formula:

    =TEXT((ROW(1:1)-1)*TIME(0,30,0)+TIME(8,0,0),"hh:mm AM/PM") & " to " & TEXT((ROW(1:1))*TIME(0,30,0)+TIME(8,0,0),"hh:mm AM/PM")
    

    Change each of the TIME(8,0,0) to the first hour you want to show.

    If you want a different time block than 30 minutes, change each TIME(0,30,0) to the span desired.

    enter image description here