方法:先添加一个宏,然后起名。这里实例起名为MyRound
然后编辑宏弹出VBA编程窗口,在下面模块中输入:系统生成的Sub Myround之类的全部删掉。)
Function myRoundByVal num As Single, ByVal dec As Integer) As Single
With Application.WorksheetFunction
num = num * .Power10, dec)
num1 = .RoundDownnum, 0)
num2 = num – num1
If num2 > 0.5 Or num2 = 0.5 And Absnum1 / 2 – Roundnum1 / 2, 0)) > 0.00001) Then num1 = num1 + 1
num1 = num1 / .Power10, dec)
End With
myRound = num1
End Function
保存后,然后在单元格中输入=myRound(单元格,小数点位数)即可