If cell, highlight

bradg12

New Member
Joined
Jul 11, 2011
Messages
10
Hi All,

I've created a roster in excel for my workplace.

I'm using a few drop down menus, to allow the person creating the roster to select from a list of times in the start and finish columns, along with a formula that finds the difference between the dates to show the number of hours working.

What I want to do, in addition to this, is add another page which displays the shifts in a bar graph type style. I've included a screenshot of how it would look with me physically doing it.

I'm thinking for the formula it needs to be something like;

in the 830 box, if the start time is between this time, colour the cell.

Any ideas on where to start?

Roster:
roster.png


Graph I want to create based on roster start and finish times
bargraph.png
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Considering the following layout:

Excel Workbook
ABCDEFGHIJKLMNOPQRS
1Sunday******************
2*8:309:009:3010:0010:3011:0011:3012:0012:3013:0013:3014:0014:3015:0015:3016:0016:3017:00
3person1******************
4person2******************
5person3******************
6*******************
7*******************
8*******************
9*7/3/20117/4/20117/5/20117/6/20117/7/20117/8/20117/9/2011***********
10*SundayMondayTuesdayWednesdayThursdayFridaySaturday***********
11person112:00*****************
12*19:00*****************
13person212:0012:00****************
14*16:0015:00****************
15person3******************
16*******************
Sheet1


Do the following:
- Select cells B3:S5
- In the Excel menu go to Conditional Formatting > New Rule
- Choose the Rule Type: Use a formula to determine which cells to format
- Use the following format:
Code:
=AND(B$2 >= INDEX($B$11:$H$16, MATCH($A3,$A$11:$A$16,0), MATCH($A$1,$B$10:$H$10,0)), B$2 <= INDEX($B$11:$H$16, MATCH($A3,$A$11:$A$16,0)+1, MATCH($A$1,$B$10:$H$10,0)))
- Choose the format of your liking using the Format button.
 
Upvote 0
Hey Moonfish,

Thanks for taking a look at this one.

I've setup exactly what you've got here, and entered the formula into the cells you asked to do.

Nothing happened though :-s

huh.png
 
Upvote 0
I'm not familiar with the layout of your version of Excel. Which version / OS are you using?

The asterisks were only to keep my table properly formatted here on the forums. A cell that contains only an asterisk in my example should be empty in Excel.


The main reason it's not working is because you didn't copy everything. The row with days is used as a means of reference.
Try entering 'Sunday' in cell B10 (without the apostrophes).
 
Upvote 0
Sorry for jumping the gun on that one!

Adding in Sunday worked like a charm, very smart.

Thanks a lot for that mate :)

Is the date used for anything? Do I need to keep that field in.
 
Upvote 0
Nope, I was only trying to replicate the layout from your initial screenshots.

If you change the formula around a bit you can fill this chart directly from your original Roster, without any additional required cells.

You might want to look into the way this formula works because it's currently set up to support only 3 different people. If you ever want to change this, or change your layout, you'll be better off knowing what you got ;)

Here's my attempt at explaining the formula:
Code:
=AND(
     B$2 >= INDEX($B$11:$H$16,
          MATCH($A3,$A$11:$A$16,0),
          MATCH($A$1,$B$10:$H$10,0)
     ),
     B$2 <= INDEX($B$11:$H$16,
          MATCH($A3,$A$11:$A$16,0)+1,
          MATCH($A$1,$B$10:$H$10,0)
     )
)
  • All references are made from the top left part of the area you wish to format conditionally. In your case, this is B3.
  • There are two criteria for a field to be colored, they are contained in the AND() function. The first is the starting time, the second is the end time.
  • The B$2 reference points to the time stamps in row 2. When considering to color C5, it will refer to C$2. The dollar sign keeps the row number from changing.
  • INDEX(range,match(),match()) is used to find a value in a table, typically based on the row and column headers. In this case, the range is the roster. The first match compares the name of the person on the left of the graph with the name of the people in the roster. The second match compares the day of the graph to the day in the roster.
  • The whole thing is then repeated in the second half of the AND statement, with the addition of a +1 to the first match, to find the end time.

If you want to visualize your referrences, take the formula used to format your graph and copy it to cell B3 of your spreadsheet. While your cursor is inside the B3 cell, all different cell references should be highlighted with various colors.
 
Upvote 0
Again, thanks.

I've been able to extend that to some more people other then the three in the original script.

The only problem I'm having is, if I enter a 16:00 shift, it'll start highlighting at 16:15

BAR.png


Anyway to make it start highlighting from 16:00.

Oddly enough, if I enter a 8:45 it'll start from 8:45.
 
Upvote 0
Code:
=and(b$12 >= index($b$33:$h$38, match($a13,$a$33:$a$38,0), match($a$1,$b$32:$h$32,0)), b$12 <= index($b$33:$h$38, match($a13,$a$33:$a$38,0)+1, match($a$1,$b$32:$h$32,0)))
 
Upvote 0
Werid enough-

If I enter the time in, 17:45 it'll highlight the 17:45 cell.

If I gather the start time thru ='ROSTER TEMPLETE'!B8 which is the cell I select the time from a drop down menu, it'll highlight 18:00.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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