ksbawpn
ksbawpn

Reputation: 322

Create a Calendar from Timeframes / Conditional Formatting if an Object is inside a certain timeframe

I have a Sheet (Sheet1) with objects and times when they are active.

Objects    Begin       End    
Object 1   1/1 2AM     1/2 6AM
Object 1   1/2 12AM    1/2 6PM 
Object 1   ..          ..
Object 2   ..          ..
Object 2   ..          ..
..
..
..

In another Worksheet (Sheet 2) I want a list of all my objects and an array of time blocks, where there is a 1 (or TRUE, ..) each time the time block is one, where the object was active.

The table should look like this

Time       1/1 12 AM      1/1 1 AM     1/1 2 AM    [..]    1/2 12 AM    [..]
Object 1       0             0             1       [..]        1
Object 2      ...
Object 3      ...
....

I don't known how to handle multiple rows for object 1, while there is only one row for object 1 in Sheet 2. If there was only one I guess something like

IF(AND(A2=Sheet2!A2, AND(Sheet2!B2>=A2, Sheet2!C2<A2)) 

Would do the trick?

Happy for any help.

Upvotes: 0

Views: 30

Answers (1)

Tom Sharpe
Tom Sharpe

Reputation: 34265

The easiest way is to use a Countifs:

=countifs(Sheet1!$A:$A,$A2,Sheet1!$B:$B,"<="&B$1,Sheet1!$B:$B,">="&B$1)

enter image description here

Upvotes: 1

Related Questions