0

1 つのセルに小文字がいくつあるか、大文字がいくつあるか、特殊文字がいくつあるかを数えたいと思います。どうすればこのようなことを達成できますか?

4

2 に答える 2

2

次の 4 つのユーザー定義関数を検討してください。

Public Function LowC(r As Range) As Long
    Dim s As String, ch As String
    Dim IAmTheCount As Long, L As Long
    s = r.Text
    IAmTheCount = 0
    For L = 1 To Len(s)
        If Mid(s, L, 1) Like "[a-z]" Then
            IAmTheCount = IAmTheCount + 1
        End If
    Next L
    LowC = IAmTheCount
End Function

Public Function HighC(r As Range) As Long
    Dim s As String, ch As String
    Dim IAmTheCount As Long, L As Long
    s = r.Text
    IAmTheCount = 0
    For L = 1 To Len(s)
        If Mid(s, L, 1) Like "[A-Z]" Then
            IAmTheCount = IAmTheCount + 1
        End If
    Next L
    HighC = IAmTheCount
End Function

Public Function NumC(r As Range) As Long
    Dim s As String, ch As String
    Dim IAmTheCount As Long, L As Long
    s = r.Text
    IAmTheCount = 0
    For L = 1 To Len(s)
        If Mid(s, L, 1) Like "[0-9]" Then
            IAmTheCount = IAmTheCount + 1
        End If
    Next L
    NumC = IAmTheCount
End Function

Public Function OtherC(r As Range) As Long
    OtherC = Len(r.Text) - LowC(r) - HighC(r) - NumC(r)
End Function

単一のセル内の大文字、小文字、数字、およびその他の文字の数を返します。

于 2013-11-10T14:45:46.053 に答える