Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi All,
I use the code to highlight those weekend columns but it also highlights the blank cell column even though I added the code for the blank cell. Where went wrong, please ?
I use the code to highlight those weekend columns but it also highlights the blank cell column even though I added the code for the blank cell. Where went wrong, please ?
VBA Code:
Sub FindWeekendCol13()
Dim rng As Range
Dim lastRow As Long
Dim rngCol As Range
Dim lastCol As Long
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = Range("C1", Range("AL" & lastRow))
For Each rngCol In rng.Columns
rngCol.Cells.Interior.Color = xlNone
'Debug.Print rngCol.Address
If IsWeekend(rngCol.Cells(1)) = True Then
ngCol.Cells.Interior.Color = RGB(255, 245, 230)
ElseIf rngCol.Cells(1).Value = "" Then
rngCol.Cells.Interior.Color = xlNone
Else
rngCol.Cells.Interior.Color = xlNone
End If
Next rngCol
End Sub