在 Excel 中将文本转换为数字格式

发布于 2024-09-19 08:33:17 字数 249 浏览 4 评论 0原文

如何将数字的文本表示形式转换为 Excel 数字,尤其是负值?例如,字符串“9,669.34”(不带引号)应变为数字 9,669.34,字符串“2,553.57-”(同样不带引号)应变为数字 (2,553.57)

当我使用公式 =SUBSTITUTE(A1,CHAR(160),"")+0 时,它效果很好,但仅适用于正值。我收到了所有负值的结果 #VALUE!

How can I convert text representations of numbers into Excel numbers, especially negative values? For example, the string "9,669.34" (without quotes) should become the number 9,669.34 and the string "2,553.57-" (again, without quotes) should become the number (2,553.57).

When I used the formula =SUBSTITUTE(A1,CHAR(160),"")+0, it worked well, but only for positive values. I received the result #VALUE! for all negative values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野侃 2024-09-26 08:33:17

对于 (2,553.57),您可以使用 VALUE,例如 VALUE("(2,553.57)")

当 2,553.57- 是字符串时,Excel 似乎无法将其识别为有效数字,因此假设 A1 中的值为“2,553.57-”,则需要做更多工作:

=VALUE(IF (RIGHT(A2,1)="-","-"&SUBSTITUTE(A2,"-","")))

编辑

=VALUE(IF(RIGHT(A2,1)="-","-"&SUBSTITUTE(A2,"-",""),A2))

来自 Microsoft 网站:

  • 文本可以是采用任何可识别的常数、日期或时间格式
    由微软Excel。如果文本不是这些格式之一,则 VALUE 返回
    #价值!误差值。
  • 通常不需要在公式中使用 VALUE 函数,因为 Excel
    根据需要自动将文本转换为数字。提供了这个功能
    为了与其他电子表格程序兼容。

更多信息可以在 Microsoft 网站上找到:价值函数

For (2,553.57), you can use VALUE, such as VALUE("(2,553.57)").

Excel doesn't seem to recognize 2,553.57- as a valid number when it is a string, so assuming you have a value of "2,553.57-" in A1, you would have to do a little more work:

=VALUE(IF(RIGHT(A2,1)="-","-"&SUBSTITUTE(A2,"-","")))

EDIT

=VALUE(IF(RIGHT(A2,1)="-","-"&SUBSTITUTE(A2,"-",""),A2))

From the Microsoft site:

  • Text can be in any of the constant number, date, or time formats recognized
    by Microsoft Excel. If text is not in one of these formats, VALUE returns the
    #VALUE! error value.
  • You do not generally need to use the VALUE function in a formula because Excel
    automatically converts text to numbers as necessary. This function is provided
    for compatibility with other spreadsheet programs.

More information can be found at Microsoft's website: Value Function

夜雨飘雪 2024-09-26 08:33:17

如果您有一列包含这些基于文本的数字,请选择该列并使用数据 ► 数据工具 ► 文本到列 ► 固定宽度 ► 完成。尾随的负号将用于确定结果数字的符号,空格(前导和/或尾随)将被删除,您将留下可以应用货币或数字格式的原始数字。

如果该列最初的格式为文本,请在应用文本到列命令之前将其更改为常规

If you have a column of these text-based numbers, select the column and use Data ► Data Tools ► Text to Columns ► Fixed Width ► Finish. The trailing negative signs will be used to determine the sign of the resulting number, spaces (leading and/or trailing) will be removed and you will be left with raw numbers that you can apply a currency or number format to.

If the column is originally formatted as Text, change it to General before applying the Text to Columns command.

岁月静好 2024-09-26 08:33:17

另一个选项:选择列。复制。使用“乘法”选项选择性粘贴。

然后,如上所述,您可以在下拉列表中选择货币或数字、小数位数等。

Another option: Select the column. Copy. Paste Special with "Multiply" option.

Then, as above, you can select Currency or Number in the droplist, decimal places, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文