范围公式问题

时间:2020-05-24 18:29:35

标签: excel vba excel-formula range

大家好,我有下一个问题,我有这段代码:

Public Function AsentamientosCA(celda As String, cotaInst As Single, Zona As String, DensidadZona As Single, _
                                alturaLlenobajocelda As Single, PB As Boolean)

set ws= ThisWorkbook.Worksheets("hojaDestino")
RangoFechaAs = "A7:A" & DatosFechaL.Rows.Count + 6
ws.Range(Replace(RangoFechaAs, "A", "F")).Formula = "=C7 -" & cotaInst & "-(D7/100)"

End Function

Sub test()

dim celda As String, cotaInst As Single, Zona As String, DensidadZona As Single
dim alturaLlenobajocelda As Single, PB As Boolean

cotaInst = ThisWorkbook.Worksheets("a").Range("A2").Value
''CotaInst = 240.2 in my pc
'' in other computers CotaInst = 240,2

call AsentamientosCA(400, cotaInst, "2A", 21, 90, True)
End Sub


在我的电脑上工作正常,但是当我在其他电脑上共享此代码时,失败了,并且失败的原因完全是因为我的电脑中的 cotaInst 被认为是240.2 pc设为240,2,假设我的代码中有一个外部变量,有没有办法更改此变量?

因为我希望此公式在具有宏的任何pc中运行。我感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

这是由于不同的州设置而发生的。在您的PC中,小数点分隔符是val df : DataFrame = ??? df.cache() // if that fits into memory val uniqueKeys = Seq("ID") val noDuplicates = df.groupBy(uniqueKeys.head,uniqueKeys.tail:_*).count().where($"count">0).isEmpty val notAlreadyExistsInTarget = spark.table(<targettable>).join(df,uniqueKeys,"leftsemi").isEmpty if(noDuplicates && notAlreadyExistsInTarget) { df.write // persist to your datastore } else { throw new Exception("df contains duplicates / already exists") } ,而在另一台PC中,十进制分隔符是.。尝试以下(未经测试

在这里,我将,更改为cotaInst As Single,并添加了几行内容以检查小数点分隔符。

cotaInst As String