gpt4 book ai didi

excel - 如何使用Excel VBA round()进行四舍五入?

转载 作者:行者123 更新时间:2023-12-01 18:19:23 24 4
gpt4 key购买 nike

我有以下数据:

cell(1,1) = 2878.75
cell(1,2) = $31.10
cell(2,1) = $89,529.13

但是,当我尝试使用 round(cells(1,1).value*cells(1,2).value),2) 时,结果与 cell(2,1) 不匹配。我认为这与舍入问题有关,但我只是想知道是否有可能得到 round()才能正常行动。也就是说,对于 value > 0.5 , 围捕。对于value < 0.5 ,向下舍入?

最佳答案

VBA 使用bankers rounding试图补偿始终向上或向下舍入 0.5 的偏差;你可以改为;

WorksheetFunction.Round(cells(1,1).value * cells(1,2).value, 2)

关于excel - 如何使用Excel VBA round()进行四舍五入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16017501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com