Format a number with optional decimal places in Excel

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Format a number with optional decimal places in Excel

Message par Clippy »

Format a number with optional decimal places in Excel
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Format a number with optional decimal places in Excel

Message par Clippy »

Alternatively, you can solve the "optional" decimal point problem using the following solution:

Number Format: `General;[Red](General)`

This will add the decimal place and fractional value accordingly, while formatting negative numbers in a more legible way.

As for the poster's original question, you still need to round/truncate the "extra" decimal points using a formula. However, this is a simple formula of `=ROUND(,)` that is not extremely computationally expensive.

Examples:

```
2500 -> 2500
0.25 -> 0.25
-2500 -> (2500)
-0.25 -> (0.25)

```
Répondre

Revenir à « Excel & VBA »