Funcția VBA Round rotunjește un număr la numărul specificat de zecimale.
Round(număr, număr_de_semne_zecimale)
Folosind funcția Round pentru a rotunji un număr la 2 zecimale:
Sub RoundExample1()
number = 12.3456
round = Round(number, 2)
MsgBox round 'Returnări la 12.35
End Sub
Folosind funcția Round pentru a rotunji diferite valori numerice:
Sub RoundExample2()
MsgBox Round(14.2) 'Returnări: 14
MsgBox Round(-14.2) 'Returnări: -14
MsgBox Round("14.2") 'Returnări: 14
MsgBox Round("-14.2") 'Returnări: -14
MsgBox Round(9.5) 'Returnări: 10
MsgBox Round(-9.5) 'Returnări: -10
MsgBox Round(1.25, 1) 'Returnări: 1.2
MsgBox Round(50, 1) 'Returnări: 50
MsgBox Round(4532.6351, 2) 'Returnări: 4532,64
End Sub