简体   繁体   English

Excel:检查单元格是否包含文本字符串中的数字

[英]Excel: Check if cell contains number in text string

I have a worksheet with text strings in each cell (article title). 我有一个工作表在每个单元格(文章标题)中有文本字符串。 I'd like to know if a cell contains a number. 我想知道一个单元格是否包含数字。 For example: 例如:

'This is 3' --> TRUE
'Red balloon' --> FALSE
' It's 10 things' --> TRUE

Update : Every answer on here works. 更新 :这里的每个答案都有效。 I just chose the shortest and simplest. 我只选择最短最简单的。

与XOR LX的答案类似但是2个字符更短

=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A1))>0

Here is one formula that would do it using average: 这是一个使用平均值来完成它的公式:

=LEN(A1)<>AVERAGE((LEN(SUBSTITUTE(A1,{0,1,2,3,4,5,6,7,8,9},""))))

or you could use small: 或者你可以使用小:

=LEN(A1)<>SMALL(LEN(SUBSTITUTE(A1,{0,1,2,3,4,5,6,7,8,9},"")),1)

Not a very rigorous description, I'm afraid. 我担心的不是一个非常严格的描述。

Perhaps: 也许:

=OR(COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A1)))

Regards 问候

If you need a VBA function: 如果您需要VBA功能:

Public Function NumberInThere(r As Range)
    Dim v As String, L As Long, i As Long
    NumberInThere = False
    v = r.Text
    L = Len(v)

    For i = 1 To L
        If IsNumeric(Mid(v, i, 1)) Then
            NumberInThere = True
        End If
    Next i
End Function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 结合使用VBA和Excel 2007将字符串中存储的数字与包含以文本格式设置的数字的单元格进行比较 - Using VBA with excel 2007 to compare a number stored in a string to a cell which contains a number formatted as text 检查文本字符串是否在Excel中包含特殊字符 - Check if a text string contains special characters in excel 如何检查Excel电子表格中的单元格是否包含数字 - How can I check if a cell in Excel spreadsheet contains number 公式,如果一个单元格的文本字符串中包含数字,则将其显示在另一个单元格中 - formula that if a cell contains a number in a string of text it displays it in another cell Excel VBA - 检查单元格是否包含文本 - Excel VBA - Check cell whether it contains piece of text Excel VBA在混合数据时检查单元格是否包含字符串 - Excel VBA check if a cell contains a string when data is mixed 检查一个Excel文件中的文本字符串是否包含在另一个Excel文件中 - Check if a text string in one excel file contains in another excel file excel:如果包含文本字符串,如何返回整个单元格 - excel : how to return the entire cell if it contains a text string 检查字符串是否包含数字 - Check if string contains number 检查字符串是否包含某些没有 CStr 转换的数字 - Excel VBA - Check if String contains certain Number without CStr conversion - Excel VBA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM