SOLVED

Change weekend collumn background colour

Brass Contributor

Hello,

 

I would like to change the background colour if the date says it is weekend.

I now have this:

GKE2019_0-1649681441999.png

It works but for a bit, I would like that only the weekends are highlighted.

And that it would stop when there is no more string/text found at A.

 

Right now I use this code

 

 

Dim r As Range, c As Range
Set r = Range(Range("G2"), Range("NG2").End(xlDown))
For Each c In r
If Weekday(c) = 6 Or Weekday(c) = 7 Then
c.Interior.ColorIndex = 3
End If
Next c

 

 

What can I do to make it work?

1 Reply
best response confirmed by GKE2019 (Brass Contributor)
Solution

@GKE2019 No need for a macro. Use Conditional Formatting in stead. 

Select the range you want to affect , including the date header. On the Home ribbon, select Conditional formatting. Add a new rule using a formula like this:

 

=WEEKDAY(B$2)>=6

 

Where B2 is the first date in the top left corner (see picture).

Riny_van_Eekelen_1-1649683500647.png

 

1 best response

Accepted Solutions
best response confirmed by GKE2019 (Brass Contributor)
Solution

@GKE2019 No need for a macro. Use Conditional Formatting in stead. 

Select the range you want to affect , including the date header. On the Home ribbon, select Conditional formatting. Add a new rule using a formula like this:

 

=WEEKDAY(B$2)>=6

 

Where B2 is the first date in the top left corner (see picture).

Riny_van_Eekelen_1-1649683500647.png

 

View solution in original post