I'm trying to use a CountIf in Excel (2010) with a formula as criteria. Something like this:
=CountIf(rawdata!$AK:$AK;bitAnd(rawdata!$AK:$AK;F$3))
whereas BitAnd is a user-defined VBA function for a bitwise AND-operation:
Public Function bitAnd(a As Integer, b As Integer) As Integer
bitAnd = a And b
End Function
The task is to count all rows that have a certain bit flag set. For example, I'd like to count all rows that have its LSB set to 1 (such as 0001, 0101,...). That is, to do something like this (in pseudo-code):
IF bitAnd(1;any number in the range) == 1 THEN count
Obviously this doesn't work with CountIf, but is there any other elegant solution using formulas (instead of coding custom functions in VBA)? Any suggestions?