Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi Everybody,
How to make the code works - I want to check if totol amount of cells contain blank cell, "AL" and/or "VL" in a column more than 2 but this is applicable in workdays only.
How to make the code works - I want to check if totol amount of cells contain blank cell, "AL" and/or "VL" in a column more than 2 but this is applicable in workdays only.
VBA Code:
Option Explicit
Sub CheckLvCol()
Dim rng As Range
Dim lastrow As Long
Dim rngCol As Range
Dim sVal As Boolean
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
lastrowd = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("C1", Range("AL" & lastrow))
rngCol.Cells(2).Font.Color = vbBlack
For Each rngCol In rng.Columns
'Restrict conditions to WORKDAYS ONLY
'=IF(WORKDAY((C1-1),1,TableNew[Holidays (A2:End)])=C1,IF(SUM(COUNTIFS(Table22[(5)],{"","AL","VL"}))>2,3,0),0)=3
'sVal=application.WorksheetFunction.IF(WORKDAY((rngcol.Cells(1)-1),1,sheets("Data").range("A2:A"&lastrow1)=rngCol.Cells(1),IF(SUM(COUNTIFS(rngCol,{"","AL","VL"}))>2,3,0),0)=3
sVal=evaluate("IF(WORKDAY((rngcol.Cells(1)-1),1, Sheets("Data").Range("A2:A" & lastrowd)=rngCol.Cells(1), IF(SUM(COUNTIFS(rngCol,{"","AL","VL"}))>2,3,0),0)=3")
If sVal = True Then
rngCol.Cells(2).Font.Color = vbRed
Else
rngCol.Cells(2).Font.Color = vbBlack
Next rngCol
End Sub