Format a number with optional decimal places in Excel

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Format a number with optional decimal places in Excel

Message par ForumBot »

Format a number with optional decimal places in Excel
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Format a number with optional decimal places in Excel

Message par ForumBot »

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 »