简体   繁体   English

从Excel中的字符串中提取数字

[英]Extract a number from a string in Excel

I have a column with data that looks like: 我有一列的数据看起来像:

7-Day: 320  (5.6%)

I need to extract the 320 as a number. 我需要将320提取为数字。 It is not always a 3 digit though. 但是,它并不总是3位数。 The value can range from 0 - 9999. And if it is 0, the percent is not calculated. 该值的范围为0-9999。如果为0,则不计算百分比。

A larger block from the column: 列中的一个较大的块:

7-Day: 0
7-Day: 320  (5.6%)
7-Day: 325  (5.5%)
7-Day: 472  (8.5%)
7-Day: 89  (2.5%)
7-Day: 258  (4.4%)
7-Day: 499  (8.7%)
7-Day: 143  (2.4%)

Thanks. 谢谢。

Try 尝试

=MID(A1,FIND(" ",A1)+1,3)+0

The formula takes the three characters following the first space, then adds a zero, which will coerce text into numbers and ignore spaces. 该公式在第一个空格后使用三个字符,然后添加一个零,这会将文本强制转换为数字并忽略空格。

Copying the data sample from above into Excel, the spaces are non-breaking spaces (character 160), but I assume that in your spreadsheet you will have normal spaces. 从上方将数据样本复制到Excel中,这些空格是不间断空格(字符160),但是我认为在电子表格中您将拥有普通空格。 If your original data has non-breaking spaces, you can use 如果您的原始数据有不间断的空格,则可以使用

=SUBSTITUTE(MID(A3,FIND(" ",A3)+1,3),CHAR(160),"")+0

If your data always starts with the seven characters: 如果您的数据始终以七个字符开头:

7-Day:

Then in B1 enter: 然后在B1中输入:

=IF(RIGHT(A1,1)="0",0,MID(A1,8,FIND(CHAR(160),A1)-8))

and copy down: 并抄下来:

在此处输入图片说明

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

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