Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi Guys,
I want to apply the below function in a vba module. Please help how it should be. Thanks
Count the total number of blank cells, "AL" and "VL" from cells 3 to end of last row in a column
Application.WorksheetFunction.If(Sum(CountIfs(Range(vRngCol.Cells(3), vRngCol.Cells(vLastRow)), "", "AL", "VL")) > 2, "True", "False") = True
Debug finds error in IF(SUM(COUNTIFS .
I want to apply the below function in a vba module. Please help how it should be. Thanks
Count the total number of blank cells, "AL" and "VL" from cells 3 to end of last row in a column
Application.WorksheetFunction.If(Sum(CountIfs(Range(vRngCol.Cells(3), vRngCol.Cells(vLastRow)), "", "AL", "VL")) > 2, "True", "False") = True
Debug finds error in IF(SUM(COUNTIFS .
VBA Code:
Sub GetAbsence15()
Dim vRng As Range
Dim vLastRow As Long
Dim vRngCol As Range
With ThisWorkbook.ActiveSheet
vLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set vRng = Range("C1", Range("AL" & vLastRow))
For Each vRngCol In vRng.Columns
If IsWeekend(vRngCol.Cells(1)) = False Then
With Columns(vRngCol.Column)
'Count total number of blank cells, "AL" and "VL" from the 3rd row till lastrow in a column
Dim LvTtl As Boolean
LvTtl = Application.WorksheetFunction.If(Sum(CountIfs(Range(vRngCol.Cells(3), vRngCol.Cells(vLastRow)), "", "AL", "VL")) > 2, "True", "False") = True
If LvTtl = True Then
vRngCol.Cells(2).Font.Size = 18
End With
Else
vRngCol.Cells(2).Font.Size = 12
End If
Next vRngCol
End With
End Sub