VBA Round Function VBA Round Function vba vba

VBA Round Function


There are two ways that you can do that.

-Select your range and change the number format:

Range("myrange").SelectSelection.NumberFormat = "0.00"

-Loop through all the cells in your range and apply the Round function to each of them. In VBA you won't be able to use the Round function on a whole range at one time.

For Each currentcell In myRange    currentcell.Value = Math.Round(currentcell.Value, 2)Next

(pseudocode above; you'll need a better For..Next loop to loop through all the cells in your range.)