Warm tip: This article is reproduced from serverfault.com, please click

excel-如何将小数点转换为小数逗号?

(excel - How do I change decimal dot into decimal comma?)

发布于 2020-11-28 14:04:13

我有一列包含带有混合小数点分隔符的数字。
例子

我需要使用“,”作为分隔符。

如何将点转换为逗号?

With ThisWorkbook.Worksheets("RAW").Range("A1")
    .Value = Replace(.Value, ".", ",")
End With

点存储为文本
看它

有什么办法可以将其存储为通用/数字?

我试过了

With ThisWorkbook.Worksheets("RAW").Range("A1")
    .NumberFormat = "General"
    .Value = Replace(.Value, ".", ",")
    .NumberFormat = "General"
    .Value = .Value
End With
Questioner
k.Sz
Viewed
11
JvdV 2020-11-28 23:35:54

一个单元格可以通过以下方法快速解决:

.Value = Replace(.Value, ".", ",")*1

或者:

.Value = CSng(Replace(.Value, ".", ","))

如果碰巧需要处理的范围,可以使用:

Sub Test()

With ThisWorkbook.Worksheets("RAW").Range("A1:A3")
    .Replace ".", ","
    .TextToColumns
End With

End Sub

每列:

Sub Test()

With ThisWorkbook.Worksheets("RAW").Range("C2:D4")
    .Replace ".", ","
    For Each col In .Columns
        col.TextToColumns
    Next
End With

End Sub