Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Handling Negative Numbers in a Complex Custom Format.

Handling Negative Numbers in a Complex Custom Format

Written by Allen Wyatt (last updated August 25, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


1

Douglas is having some problems getting his head around a custom format he needs. He has created a custom format that displays large numbers the way he wants, such that $1,000,000 is displayed as $1.0M and $1,000 is displayed as $1.0K. This format is as follows: [>1000000]$#.0,,"M";[>1000]$#.0,"K";$#,##0.0. Douglas wants to know how to adjust the custom format so that negative numbers appear in this same fashion, but in red with parentheses around them, like ($1.0K).

Unfortunately, what you want to do is not possible with a single custom format. The reason is because a single custom format can only have four conditions, each separated by a semicolon. This is the general syntax of a custom format:

positive; negative; zero; text

Note that the first format is used when the value is positive, the second when it is negative, the third when the value is exactly zero, and the fourth when the value is text. While this is the general syntax for custom formats, you can "fudge" the formats a little in the way you are doing. Consider the format you are using:

[>1000000]$#.0,,"M";[>1000]$#.0,"K";$#,##0.0

Note that according to the general syntax, the format before the first semicolon would be used for positive values, the next format for negative values, and the third for zero values. However, this is not the way in which Excel translates this custom format. It translates it as "if greater than 1,000,000, do this; if greater than 1,000 do this; else do this". There is no positive or negative connotation in the format; in fact, any negative values are treated to the default treatment, which is the third format.

What you are trying to do is to define two positive conditions (one for millions and one for thousands) and two negative conditions (again, for millions and thousands). This cannot be done in a single custom format, regardless of how you try to put it together. Instead, you should use two custom formats, such as these:

[>=1000000]$#.0,,"M ";[>=1000]$#.0,"K ";$#,##0.0
[Red][<=-1000000]($#.0,,"M");[Red][<=-1000]($#.0,"K");[Red]($#,##0.0)

The first format is to be used in the case of positive values; it is a variation on the original format suggested at the first of the tip. The second format is to be used with negative values. These custom formats will need to be manually applied, based upon the value in the cell.

This may seem like a lot of work to go through to get the formatting you want. It is possible to create a macro that applies the formats, but the macro would not be a trivial endeavor. It would need to check what the value in the cell is, pick the proper format, construct the format, stuff it into the custom format for the cell, and then move on to the next cell.

Some people may also think you could use conditional formatting in this case. Conditional formatting doesn't allow you to modify the presentation of the number in the cell, however. While you can check for the value (more than a thousand or a million, for instance), you cannot then divide, round, and add a suffix to the value in the cell. Nor can you do things like add parentheses to negative values.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10226) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Handling Negative Numbers in a Complex Custom Format.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Automatically Saving Changes to Defaults

Have you ever started a new document only to find that the settings in Word seem to be different than what you expected? ...

Discover More

Using Fields for Fractions

Want a quick way to create fractions? You can do it by using fields, as described in this tip.

Discover More

Turning Off Smart Quotes for Specific Styles

Smart quotes can be helpful in making a great-looking document, but at times, they can be a real pain. Wouldn’t it be ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Moving Custom Formats to Number Formatting Categories

Moving your custom formats into a formatting category other than "custom" isn't something you can do in Excel. Here's ...

Discover More

Merge and Center Not Available

What are you to do if you are trying to format a worksheet, only to find out that one of the tools you need is not ...

Discover More

Notation for Thousands and Millions

When working with very large numbers in a worksheet, you may want the numbers to appear in a shortened notation, with an ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 1?

2017-12-11 19:47:40

Santiago Clausse

Hi,

I just wanted to provide an update regarding this topic.

Conditional formatting now does allow you to change the number format of the cell. So I've created a new rule for cell value less than 0, and it changes the formatting to: [Red][<=-1000000](€#.0,,"M");[Red][<=-1000](€#,"K")

Hope that helps!

All the best,


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.