且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查单元格是否在Excel中包含非字母字符

更新时间:2023-02-13 16:27:07

有一个怪异"但简单而通用的答案.

There is a "weird" but simple and generic answer.

=SUMPRODUCT(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),"abcdefghijklmnopqrstuvwxyz"))

  • 如果A1包含任何非字母字符,则此公式返回#VALUE!错误;如果A1仅包含字母,则该公式返回数字;如果A1为空白,则返回#REF!错误.

    • This formula returns #VALUE! error if A1 contains any non-letter characters, number if A1 contains only letters, or #REF! error if A1 is blank.

      您可以将此公式包含在ISNUMBERISERR中,以将其转换为TRUE/FALSE值.

      You can enclose this formula in an ISNUMBER or ISERR to convert this to a TRUE/FALSE value.

      SEARCH替换为FIND以使其区分大小写.

      Replace the SEARCH with a FIND to make it case sensitive.

      您可以在"abc...xyz"字符串中放置任何字符.这样可以轻松测试字母数字或常见标点符号等.

      You can put any character in the "abc...xyz" string. This makes it easy to test of alphanumeric, or common punctuations, etc.

      "1:"&LEN(A1)表示将从第一个字母开始一直检查到最后一个字母.将其更改为"2:"&(LEN(A1)-1)不会检查首字母和尾字母.

      The "1:"&LEN(A1) means that starting from the first letter, all the way to the last letter will be checked. Changing that to "2:"&(LEN(A1)-1) will not check the first and last letters.