Highlight specific time ranges in a weekly schedule in excel
In a previous post I created a simple weekly schedule with dynamic dates.
In this post I am going to highlight hours using date and time ranges.
Here are some random ranges:
Here is a picture of the weekly schedule and affected cells highlighted grey.
Try change date in cell F2 and see how any other week has no highlighted cells (hours).
How to highlight cells in a weekly schedule (conditional formatting)
Conditional formatting does not accept cell references outside current worksheet.
But there is a work-around.
Create a named range for each column and use the named ranges in a conditional formatting formula.
Create named ranges
- Select sheet "Time ranges"
- Select range B3:B5
- Type "Start" in name boxand press Enter

- Select range C3:C5
- Type "End" in name box and press Enter
Create conditional formatting (Excel 2007)
- Select sheet "Weekly schedule"
- Select cell range C6:I30
- Click "Home" tab on the ribbon
- Click "Conditional formatting"
- Click "New Rule.."
- Click "Use a formula to determine which cells to format"
- Type in "Format values where this formula is true" window:
=SUMPRODUCT((C6>=Start)*(C6<End)) - Click "Format..." button
- Select "Fill" tab
- Select a color
- Click Ok
- Click Ok
- Click Ok
Download excel template
Highlight time ranges in a weekly schedule.xls
(Excel 97-2003 Workbook *.xls)
Functions in this article:
SUMPRODUCT(array1, array2, )
Returns the sum of the products of the corresponding ranges or arrays








January 30th, 2012 at 8:26 am
Good Day Oscar,
I would like to get your help on the following:
I would like to create a calendar within excel that would be linked to a series fo recurring events.
Those events are happening every 15 days, and expected to occur for a period of up to 15 months (so 30 times in a row).
We have about 500 events, each named with an ID code (a01,a02,a03...)
We have a database that contains the id code, the date of first manipulation and the recurring dates after that, this file is updated daily, as some schedule might have been moved +- 1 day as it is meant to be flexible.
I have seen your example with the time. We do not require any time frame, just what is due on a specific date.
The difficulty being that a single day may have up to 50 events, hence 50 ID code.
I fear my explanations are vague or misconstructed. Kindly advise if you need me to clarify te statements above.
Hoping to get some informations pertaining to my concerns.
Cheers.
Cyril.
Excel v14.1.4 2011 mac.
January 30th, 2012 at 2:38 pm
Cyril,
Interesting question! What would the calendar look like, dates in a column and up to 50 events in a single row?
Thanks for commenting!
January 31st, 2012 at 3:41 am
Hi Oscar,
Thanks for your interest in my query.
The database is organized as follows first row for the headings, data starting from row 2 till row 1205.
Column A is for the ID code, Column B for the first date (encoded by coordinator, Column C and forth (AF) for the due dates (formula), now for some instance we have events up to column CC (schedule is flexible and prone to change).
Due dates are linked and will update themselves automatically if any previous date is modified.
The Coordinator needs to see for a specific date what ID codes are due for manipulation.
Now the dates could very well be in A:A and the events (ID code) in B:BO or more if needed.
Maybe the date range (A:A) could be from 7 days prior to today() (row 2) till today()+30 days (row 39). Thus allowing the coordinator to see a whole month schedule, due events of manipulation, and monitor past week schedule (in case of delayed manipulation as I stated a possibility of schedule being moved). If this would work, the coordinator would need not update the summary but merely update the database.
Then we could use a conditional formatting with the formula $A2=TODAY() as condition in order to highlight the present day (faster to spot).
I hope my explanations are precise enough.
Please let me know if you need some more details.
Cyril.
January 31st, 2012 at 4:42 am
Oscar,
I used the following:
=INDEX(DB!$B$2:$B$459, SMALL(IF(Calendar!$B2=DB!E$2:E$459, ROW(DB!E$2:E$459)-MIN(ROW(DB!E$2:E$459))+1, ""), COLUMN($A$1)))
But I do not know if this is the best solution for what I described, and being an array I need to command enter for each cell, if I highlight the whole range and command enter, it will just copy the formula and give the first ID code in all cells (which is not what we are looking for).
Just an addition to my previous post.
DB being the database with ID in column B and dates in column C to AF (just a sample)
Calendar being the sheet with the ranged calendar as follows:
columnB date (today()-7 to today()+30
columnC row 2 =INDEX(DB!$B$2:$B$459, SMALL(IF(Calendar!$B2=DB!D$2:D$459, ROW(DB!D$2:D$459)-MIN(ROW(DB!D$2:D$459))+1, ""), COLUMN($A$1)))
columnD row 2 =INDEX(DB!$B$2:$B$459, SMALL(IF(Calendar!$B2=DB!E$2:E$459, ROW(DB!E$2:E$459)-MIN(ROW(DB!E$2:E$459))+1, ""), COLUMN($A$1)))
ect
January 31st, 2012 at 5:49 am
I eventually modified it as =IFERROR(INDEX(DB!$B$2:$B$459, SMALL(IF(Cd!$B2=DB!D$2:D$459, ROW(DB!D$2:D$459)-MIN(ROW(DB!D$2:D$459))+1, ""), ROW($A$1))),"")
But it wouldn't update itself whenever the DB file (database) would be updated.
Most likely i missed something.
Thanks to advise if my proceeds are correct or if a new direction (and formula) shall be used altogether.
February 3rd, 2012 at 3:19 am
Oscar,
Partially solved with a pivot AND merge function.
Still hoping to get some feedback if you have any idea on how to proceed to extract data from both rows and columns.
Posted in Mrexcel.com but so far you were the only one showing interest in my query...
Cheers,
Cyril.
February 3rd, 2012 at 9:04 am
Cyril,
Download *.xlsx file
cyril.xlsx
February 3rd, 2012 at 9:34 am
Oscar,
Yes, it is true,I realized my mistake after sending my reply myself (well that says a lot...) hehehe
the array is fine, command +return (mac version of ctrl+Shift+enter)
the trouble comes when duplicates are found.
The formula returns the first data and ignore all other successive entries sharing the same value (here the date).
Then what you explained in "How to return multiple values using vlookup in excel" seems to be a way to explore.
Thanks for the tip.
February 3rd, 2012 at 11:02 am
Cyril,
I changed my comment. Check out the attached file!
Download *.xlsx file
cyril.xlsx
February 3rd, 2012 at 11:16 am
Good evening Oscar,
So the range in the database (sheet1) must be the total range (all columns and rows containing info)...
I'll just change the range to accommodate more rows right?
I'll as well add drop down list for identifier (code for the coordinator)
Very sweet formula!
Kudos and many thanks for the time and sharing.
Cheers,
Cyril.

February 3rd, 2012 at 1:20 pm
Cyril,
So the range in the database (sheet1) must be the total range (all columns and rows containing info)...
I understand why you ask, the cell references didn´t have the same number of rows.
I'll just change the range to accommodate more rows right?
Yes, change every instance of Sheet1!$B$2:$AY$16.
February 4th, 2012 at 1:36 am
very nice trick, should have thought of it, was tinkering with INDEX, AND, IF... hehehe
Thanks again Oscar.