COUNTTEXTCELLS
Returns the number of cells that contain text.
This is equivalent to using the COUNTIF function directly.
| rgeValues | The range of values |
REMARKS
??
Public Function COUNTTEXTCELLS( _
ByVal regValues As Range) _
As Integer
COUNTTEXTCELLS = Application.WorksheetFunction.CountIf(rgeValues,"*")
End Function
Public Function COUNTTEXTCELLS( _
ByVal ref_value As Range, _
ByVal ref_string As String) As Long
Dim i As Integer
Dim count As Integer
count = 0
If Len(ref_string) <> 1 Then
COUNTTEXT = CVErr(xlErrValue)
Exit Function
End If
For i = 1 To Len(ref_value.Value)
If (VBA.Mid(ref_value, i, 1) = ref_string) Then
count = count + 1
End If
Next
COUNTTEXTCELLS = count
End Function
For instructions on how to add a function to a workbook refer to the page under Inserting Functions
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext