excel - 从数字中删除点

标签 excel vba replace

我有一列数字格式为常规

| 2.500,00 |
| 70,2     |
| ...      |

我有一个宏尝试删除列中的点。

当我手动执行时,结果是

| 2500,00 |
| 70,2    | 
| ...     |

当我使用以下行执行此操作时:

Selection.Replace What:=".", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

它删除了没有点的单元格中的逗号,结果如下所示:

| 2500,00 |
| 702     |
| ...     |

最佳答案

您需要将 Excel 中使用的小数分隔符更改为逗号而不是点,以匹配您的数据。

从 Microsoft 复制:Change the character used to separate thousands or decimals

Click the Microsoft Office Button Office button image, and then click Excel Options.

On the Advanced tab, under Editing options, clear the Use system separators check box.

Type new separators in the Decimal separator and Thousands separator boxes.

TIP: When you want to use the system separators again, select the Use system separators check box.

NOTE: For a permanent solution, you must change the regional settings in Control Panel.

另一个解决方案:

其实我通常做的只是使用公式来删除点并将逗号转换为点。然后使用格式来显示您想要的数字。

=VALUE(SUBSTITUTE(SUBSTITUTE(A1,".",""),",","."))

关于excel - 从数字中删除点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36203249/

相关文章:

image - 使用 VBA 在文件中插入和保留图像 - Excel 2013

r - 链式 ifelse() 导致单元格中的值 'data.frame'

vba - 右函数vba

excel - 这是我的逻辑还是我写的语法错误? (if else 语法)

excel - VBA - 为什么 VBA UDF 与 native Excel 函数相比这么慢?

html - 使用宏将数据从网站抓取到 Excel...丢失

class - vba 错误 438 但对象类确实包含子

netbeans - 在 netbeans 中使用通配符查找和替换

javascript - 替换/删除数组中的空条目

vim - Vim:小于一行的范围内的替换