Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi EveryOne,
I want to include the holidays in the function code. The holidays details is in Sheet("Data") dynamic table TableNew A2:last row of data.
Please help !!
I want to include the holidays in the function code. The holidays details is in Sheet("Data") dynamic table TableNew A2:last row of data.
Please help !!
VBA Code:
Public Function IsWeekend(InputDate As Date) As Boolean
Select Case Weekday(InputDate)
Case vbSaturday, vbSunday
IsWeekend = True
Case Else
IsWeekend = False
End Select
End Function
Sub TAbsence13()
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(2).Font.Color = vbBlack
If IsWeekend(rngCol.Cells(1)) = True Then
rngCol.Cells(2).Font.Color = vbBlue
Else
rngCol.Cells(2).Font.Color = vbBlack
End If
Next rngCol
End Sub