简体   繁体   English

公式,如果一个单元格的文本字符串中包含数字,则将其显示在另一个单元格中

[英]formula that if a cell contains a number in a string of text it displays it in another cell

I am looking for a formula in excel that if a cell contains a number in a string of text it displays that number ignoring the other text. 我在excel中寻找公式,如果单元格在文本字符串中包含数字,则该数字将忽略其他文本而显示该数字。

So if A1 contains the text "license12M", the formula in A2 displays "12". 因此,如果A1包含文本“ license12M”,则A2中的公式显示为“ 12”。

The text in the string will relate to a lot of products, but the number will be either 12,24,36,48 or 60. 字符串中的文本将涉及许多产品,但数字将为12,24,36,48或60。

Many Thanks 非常感谢

如果仅是这5个数字之一,则可以使用以下公式明确搜索这些数字

=IFERROR(LOOKUP(2,1/FIND({12,24,36,48,60},A1),{12,24,36,48,60}),"No match")

To extract any embedded number from text, try the array formula : 要从文本中提取任何嵌入的数字,请尝试使用数组公式

=MID(SUMPRODUCT(--MID("01"&A1,SMALL((ROW($1:$300)-1)*ISNUMBER(-MID("01"&A1,ROW($1:$300),1)),ROW($1:$300))+1,1),10^(300-ROW($1:$300))),2,300)

在此处输入图片说明

Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. 必须使用Ctrl + Shift + Enter输入 数组公式 ,而不仅仅是Enter键。 If this is done correctly, the formula will appear with curly braces around it in the Formula Bar. 如果正确完成此操作,则公式将在公式栏中显示为带有大括号的公式。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM