[英]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.