Darren said:
This is really just a question of wildcard syntax for use in functions such
as countif or sumif or CF etc. Nothing complicated such as direct or indirect
references to cells.
In some languages it is permitted to say "[A-D]?" in order to find 2
character values beginning with the letter A or B or C or D.
What is a comparable syntax in Excel please?
There is no comparable syntax in XL. Instead you need to combine two or
more tests.
The easiest way to meet the specification above, using XL functions, is
probably:
=SUMPRODUCT(--(LEN(rng)=2),--(rng>="A"),--(rng<"E"))
Note that, through XL04, rng cannot be an entire column, nor can it be
two-dimensional.
You could instead create a User Defined Function that would allow you to
use VBA's 'Like' comparison operator:
Public Function CountLike( _
ByRef rng As Excel.Range, _
ByVal regexp As String) As Variant
Dim rArea As Range
Dim rCell As Range
Dim nSum As Long
On Error GoTo ErrorHandler
For Each rArea In rng.Areas
For Each rCell In rArea
nSum = nSum - (rCell.Text Like regexp)
Next rCell
Next rArea
CountLike = nSum
Exit Function
ErrorHandler:
CountLike = CVErr(xlErrValue)
End Function
which you could then call as
=CountLike(A1:Z100, "[A-D]?")