JA1
JA1

Reputation: 568

Highlight X number of cells based on numeric value

I'm creating a vacation tracker in excel. The first sheet pulls the data from SharePoint which has Start Date, End Date and a Date Difference calculation.

Sheet1
A2=12/16/2015
B2=12/20/2015
C2=5

The second sheet is the visualization of the data. It starts with cell B1 and goes out for 90 days. It is a word representation of the date. Here is the formula I'm using =UPPER(TEXT(B2,"DDD"))

Sheet2
B1=WED
C1=THU
D1=FRI
E1=SAT
F1=SUN

The next row always B2 has a formula which is always today's date. From there I add one date to increment the dates out to 90 days. B2=Today() and the other cells =B2+1 and so forth

B2=16
C2=17
D2=18
E2=19
F2=20

What I'm trying to do is have the start date and end date highlighted on Sheet2. For example the boss is out on vacation from 12/16/2015 until 12/20/2015. I need the cells B3-F3 on Sheet2 highlighted in Red. The secretary who is on leave from 12/17/2015 to 12/19/2015 have her cells highlighted in another color from cells C4-E4.

This will probably take some VBA I just need a starting point. I tried using a VLOOKUP to pull the data, however the using a range from another sheet is not working. And to be honest I do not know if this is the correct approach.

Upvotes: 0

Views: 602

Answers (1)

Dirk Reichel
Dirk Reichel

Reputation: 7979

Conditional formatting for B2:ZZ2 at Sheet2

=AND(B2>=Sheet1!$A$2,B2<=Sheet1!$B$2)

And select the color you like

Upvotes: 1

Related Questions