http://wenku.baidu.com/view/d7d6ea5c3b3567ec102d8a99.html可点上面的链接下载该程序的源代码
Sub 选区字符统计()
Dim str As String, ChineseChar As Long, Alphabetic As Long, Number As Long
Dim i As Long, rng As Range, j As Long
For Each rng In Selection
j = j + Len(rng.Value) '计算字符总长度
For i = 1 To Len(rng)
str = Mid(rng.Value, i, 1)
If str Like "[一-龥]" = True Then '汉字
ChineseChar = ChineseChar + 1 '汉字累加
ElseIf str Like "[a-zA-Z]" = True Then '字母
Alphabetic = Alphabetic + 1 '字母累加
ElseIf str Like "[0-9]" = True Then '数字
Number = Number + 1 '数字累加
End If
Next
Next
MsgBox "所选单元格区域中共有字数" & j & "个。" & vbCrLf & "汉字:" & ChineseChar & "个" & _
vbCrLf & "字母:" & Alphabetic & "个" & vbCrLf & "数字:" & Number & "个" & vbCrLf _
& "特殊字符及空格:" & j - Alphabetic - Number - ChineseChar & "个。", vbInformation, "字符统计"
End Sub
简单点可用以下代码
Sub 宏2()
On Error Resume Next
MsgBox Selection.SpecialCells(xlCellTypeConstants, 1).Count
End Sub