La funzione VBA Round arrotonda un numero al numero di cifre decimali specificato.
Round(numero, numero_di_segni_decimali)
Utilizzando la funzione Round per arrotondare un numero a 2 cifre decimali:
Sub RoundExample1()
number = 12.3456
round = Round(number, 2)
MsgBox round 'Rientro alle 12.35
End Sub
Utilizzo della funzione Round per arrotondare diversi valori numerici:
Sub RoundExample2()
MsgBox Round(14.2) 'Resi: 14
MsgBox Round(-14.2) 'Rendimenti: -14
MsgBox Round("14.2") 'Resi: 14
MsgBox Round("-14.2") 'Rendimenti: -14
MsgBox Round(9.5) 'Resi: 10
MsgBox Round(-9.5) 'Rendimenti: -10
MsgBox Round(1.25, 1) 'Resi: 1.2
MsgBox Round(50, 1) 'Ritorno: 50
MsgBox Round(4532.6351, 2) 'Resi: 4532,64
End Sub