La fonction VBA Round arrondit un nombre au nombre de décimales spécifié.
Round(nombre, nombre_de_signes_décimaux)
Utilisation de la fonction Round pour arrondir un nombre à 2 décimales :
Sub RoundExample1()
number = 12.3456
round = Round(number, 2)
MsgBox round 'Retours à 12h35
End Sub
Utilisation de la fonction Round pour arrondir différentes valeurs numériques :
Sub RoundExample2()
MsgBox Round(14.2) 'Retours: 14
MsgBox Round(-14.2) 'Retours: -14
MsgBox Round("14.2") 'Retours: 14
MsgBox Round("-14.2") 'Retours: -14
MsgBox Round(9.5) 'Retours: 10
MsgBox Round(-9.5) 'Retours: -10
MsgBox Round(1.25, 1) 'Retours: 1,2
MsgBox Round(50, 1) 'Retours: 50
MsgBox Round(4532.6351, 2) 'Retours: 4532,64
End Sub