The issue arises because Excel interprets colons (:) in custom number formats as time separators (like in h:mm:ss), not as literal characters. When you use "0:00:00", Excel expects format codes like h, m, or s (e.g., h:mm:ss) to define a time format. Using 0 instead triggers an error because 0 is not a recognized time placeholder.
Solution:
To display numbers with colons as separators (e.g., 1:23:45), you must escape the colons in the custom format. Here's how:
-
Escape colons with backslashes:
- Use the format:
0\:00\:00
- Example: If you enter
123456, it will display as 1:23:45.
-
Escape colons with quotes:
- Use the format:
0":"00":"00
- Example:
123456 → 1:23:45.
Steps to Apply the Format:
- Select the cell(s) you want to format.
- Press
Ctrl + 1 to open the Format Cells dialog.
- Under the Number tab, choose Custom.
- Enter the escaped format (e.g.,
0\:00\:00).
- Click OK.
Why It Works:
- Escaping tells Excel to treat the colon as a literal character, not a time separator.
- The format
0\:00\:00 divides the number into segments:
0 = First digit.
\: = Literal colon.
00 = Next two digits.
\: = Literal colon.
00 = Final two digits.
Example:
| Input Value | Format Code | Displayed As |
|---|
| 123456 | 0\:00\:00 | 1:23:45 |
| 789 | 0\:00\:00 | 7:08:09 |
Key Notes:
- Ensure your input numbers have exactly 5 or 6 digits for the format to align correctly (e.g.,
12345 → 1:23:45).
- If you're formatting actual time values (like
1:30:45), use Excel's built-in time formats (e.g., h:mm:ss) instead of custom 0 placeholders.
By escaping the colon, you bypass Excel's time-format parsing and enforce literal character display. This method works for other reserved characters (e.g., *, +, -) too.