在excel中检测“纯”字母表

时间:2016-03-05 11:20:27

标签: excel excel-vba excel-formula excel-2013 vba

我试图区分包含字母字符数据的单元格和数字字符数据。我使用istext()& ISNUMBER()。但是当出现字母数字字符时,这种逻辑会失败。

我的目的是检测只有字母的单元格。包含数字或字母数字字符的单元格需要触发为false。

提前致谢。

5 个答案:

答案 0 :(得分:2)

=SUMPRODUCT(0+ISNUMBER(0+MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1))),1)))=0

你也可以使用CSE(CTRL + SHIFT + ENTER),稍短一点:

=COUNT(0+MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1))),1))=0

这里的构造被传递给MID的{​​{1}}参数,即:

start_num

是一个ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1)))(实际上,在工作簿上只有技术上不稳定) - 因此更可取 - 替代例如:

non-volatile

此致

答案 1 :(得分:2)

考虑这个小的 UDF()

Public Function IsLetters(s As String) As Boolean
    Dim i As Long

    IsLetters = False
    For i = 1 To Len(s)
        If Not Mid(s, i, 1) Like "[a-zA-Z]" Then Exit Function
    Next i
    IsLetters = True
End Function

enter image description here

注:

空格字符也会产生 FALSE

答案 2 :(得分:2)

你可以:

IsAlpha = len(s) > 0 and not s like "*[!A-Za-z]*"

答案 3 :(得分:0)

这是另一种可能更易于使用的方式:

=COUNT(FIND({"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q",
             "r","s","t","u","v","w","x","y","z"},A1))>0

答案 4 :(得分:-1)

您可以使用以下常规快递来测试字母。

JavaScript代码:

= / ^ [A-ZA-Z()] + $ /测试(A1)

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html

enter image description here