Application.International xlDecimalSeparator解决方法

我必须通过一个单元格的copy_paste值创build一个表格。 然后,这些值将与另一个单元格的值相乘。 问题是“xlDecimalSeparator”。 当它被设置为“。”时 没关系。 当它被使用时,问题就开始了。 (我有一个荷兰设置)。 我尝试做一个解决方法:将单元格声明为文本,然后用“。”replace“,”,将值放入单元格中,然后将单元格格式化为数字。 Everithing运作良好,除了最后有正确的价值,我必须双击单元格+input有结果的公式,否则我只是有这样的事情“= 3 * $ D $ 1”不是6(结果function)。

所以我的代码:

Sub Copy_Cell_test() Dim my_range As Range Dim strDecimal As String Dim c As Variant Application.ScreenUpdating = False strDecimal = Application.International(xlDecimalSeparator) If strDecimal = "," Then strDecimal = "." Set my_range = Worksheets("sheet_test").Range("A2:H111") With my_range For Each c In my_range If Not c.Value = "" Then c.NumberFormat = "@" c.Value = Replace(c.Value, ",", strDecimal) c.Value = "=" & c.Value& & "*$D$1" If Application.International(xlDecimalSeparator) = "," Then c.Value = Replace(c.Value, strDecimal, ",") End If c.NumberFormat = "0.00"" €/lm""" 'c.Value = c.Value <<< Here I have error if "," is set End If Next c End With Application.ScreenUpdating = True End Sub 

我该如何解决? 我尝试发送键F2 + [ENTER],但它不工作。

这与FormulaLocal为我工作。

 Option Explicit Sub Copy_Cell_test() Dim my_range As Range Dim c As Range Dim formulaText As String On Error GoTo handleErr Application.ScreenUpdating = False Set my_range = Worksheets("sheet_test").Range("A2:H111") With my_range For Each c In my_range If Not c.Value = "" Then formulaText = "=" & c.Value & "*$D$1" c.FormulaLocal = formulaText c.NumberFormat = "0.00"" €/lm""" End If Next c End With Application.ScreenUpdating = True handleErr: If Err.Number = 0 Then Exit Sub MsgBox Err.Description End Sub