Automatic rounding for a range of cells

If it is desired that, in a sheet, numerical values be formatted and displayed by rounding with a certain number of decimals, the following macro can be created. A function can be created just as well. It is important to remember that the respective cells/area must be selected. If the selection is made for the entire spreadsheet, the duration of the application of the code risks being very long, considering that Excel will “sweep” all the cells of the respective sheet.

Instead of Round., RoundUp. or RoundDown. can be used.
After selecting the required cells, the macros form is displayed using the ALT+F8 combination (if the Developer menu is not visible) where you will also find fc_rotunj.

  1. The Round function rounds a number to a specified number of digits.
  2. The RoundUp function rounds a number by addition, in the direction from 0, behaving like ROUND, except that it only rounds by addition.
  3. The RoundDown function rounds a number down, toward 0, behaving like ROUND, except that it only rounds down.

 

Sursa: StackOverflow.com, Monkidea.com

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply