Option Explicit
Public Function COUNTCASES(EvalRange As Excel.Range, _
Optional EvalExtend As Boolean = False) As String
Application.Volatile True
Dim rCell As Excel.Range
Dim lUcase As Long
Dim lLcase As Long
Dim lTcase As Long
Dim lMixCase As Long
Dim lFormula As Long
Dim lNum As Long
Dim lDate As Long
Dim lEmpty As Long
For Each rCell In EvalRange
If Not EvalExtend Then
If Not rCell.HasFormula Then
If Not IsNumeric(rCell) Then
If Not IsDate(rCell) Then
If Not IsEmpty(rCell) Then
If UCase$(rCell) = rCell Then lUcase = lUcase + 1: GoTo NextEval
If LCase$(rCell) = rCell Then lLcase = lLcase + 1: GoTo NextEval
If Application.Proper(rCell) = rCell Then lTcase = lTcase + 1: GoTo NextEval
lMixCase = lMixCase + 1: GoTo NextEval
End If
End If
End If
End If
Else
If IsEmpty(rCell) Then lEmpty = lEmpty + 1: GoTo NextEval
If rCell.HasFormula Then lFormula = lFormula + 1: GoTo NextEval
If IsNumeric(rCell) Then lNum = lNum + 1: GoTo NextEval
If IsDate(rCell) Then lDate = lDate + 1: GoTo NextEval
If UCase$(rCell) = rCell Then lUcase = lUcase + 1: GoTo NextEval
If LCase$(rCell) = rCell Then lLcase = lLcase + 1: GoTo NextEval
If Application.Proper(rCell) = rCell Then lTcase = lTcase + 1: GoTo NextEval
lMixCase = lMixCase + 1: GoTo NextEval
End If
NextEval:
Next rCell
If Not EvalExtend Then
COUNTCASES = lUcase & " UpperCase, " & _
lLcase & " LowerCase, " & _
lTcase & " ProperCase, " & _
lMixCase & " MixedCase"
Else
COUNTCASES = lUcase & " UpperCase, " & _
lLcase & " LowerCase, " & _
lTcase & " ProperCase, " & _
lMixCase & " MixedCase, " & _
lFormula & " Formula, " & _
lNum & " Numeric, " & _
lDate & " Date, " & _
lEmpty & " Empty"
End If
End Function
|