Excel VBA Rounding -


i trying use following code replace each cell within selected range rounded number of cell within range continue error.

sub add_round() dim rng range     each rng in selection         rng.value = round(rng.value, -4)     next rng  end sub 

thank you!

i believe need make function yourself, follows (i'm not aware of function in vba works excel's native round function, allows round nearest 1000 etc):

sub add_round()  dim rng range     each rng in selection         rng.value = round(rng.value / 10000, 0) * 10000     next rng  end sub 

alternatively can tell vba use native excel function this:

sub add_round()  dim rng range     each rng in selection         rng.value = application.worksheetfunction.round(rng.value, - 4)     next rng  end sub 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -