Reputation: 67
problem with correct statement
Application.WorksheetFunction.CountIf(Range("B:B-B5"), a)
i want to select an entire column minus a cell in VBA. how can I do this?
Upvotes: 0
Views: 80
Reputation: 6103
You can write a helper function for this:
Function CountIfExcept(from As range, except As range, criteria As String)
CountIfExcept = Application.WorksheetFunction.CountIf(from, criteria) - Application.WorksheetFunction.CountIf(except, criteria)
End Function
Usage:
totalCount = CountIfExcept(Range("B:B"), RANGE("B5"), "some condition")
Upvotes: 1