I'm trying to figure out how I can write a VBA code that counts how many of the cells in my range are hidden AND have a specific value.
I've tried something like this, but it doesn't work:
Sub Count_hidden_ABC()
Dim s As Long
Dim Rg As Range
Set Rg = Worksheets("Sheet1").Range("G8:G255")
s = Application.WorksheetFunction.CountIfs(Rg, "ABC", Rg, SpecialValues(12))
or
Sub Count_hidden_ABC()
Dim s As Long
Dim Rg As Range
Set Rg = Worksheets("Sheet1").Range("G8:G255")
s = Rg.SpecialCells(12).Application.WorksheetFunction.CountIf(Rg, "ABC")
Anyone has a clue how to do this?
Sub Count_hidden_ABC()
Dim s As Long
Dim Rg As Range
Dim rng As Range
Set Rg = Worksheets("Sheet1").Range("G8:G255")
For Each rng In Rg.SpecialCells(12).Areas
s = s + WorksheetFunction.CountIf(rng, "ABC")
Next
s = WorksheetFunction.CountIf(Rg, "ABC") - s
'Debug.Print s
End Sub