Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't know much about the rules on custom number formatting in Excel, and I need to learn more. When I open the related window (Format Cells > Numbers > Custom), there are some predefined formats consisting of various symbols. For example:

_-* #.##0,00 TL_-;-* #.##0,00 TL_-;_-* "-"?? TL_-;_-@_-

What does each of these symbols mean?

There is also a specific issue I want to achieve. I want to put a plus sign in front of a number if it is positive, and minus sign if it is negative. How can I do that by custom number formatting?

share|improve this question
This is not a direct answer to your question, but additional useful information: when you want to create a custom code and check if it works, put some sample data in a spreadsheet for different example you want to see (in your case +ve and -ve numbers, for example). Whatever cell you select when you go to create the new format will be used as the value for the sample shown in the formatting dialogue box. This helps get you started, and once you think it is right, apply it then use format painter to format your other example data to test. – AdamV Nov 4 '10 at 11:42
up vote 4 down vote accepted

the semicolons are delimiters for each specific criteria - the first is for postive numbers, the second for negative number, the third is for zeroes and the last is for text values.

I want to put a plus sign in front of a number if it is positive, and minus sign if it is negative. How can I do that by custom number formatting?


Should achieve what you're looking for, assuming thousands as group operator.

Each symbol tells Excel what to do

? - Placeholder - means to leave spaces for leading zeroes, but don't display them

0 - Placeholder - means explicitly display leading zeros to match the format

* - Repeat the character next to it

+ - display + sign

- - display the negative sign

You can even add conditions to the above, or add colourrs ( show negatives in red et al) - More documentation is available here

share|improve this answer
is this totalyl impossible to just ask excel to always show sign without splitting format to two or three mostly the same parts ? – Arioch 'The Feb 11 '13 at 14:04

Number formats can have at most 4 sections separated by ; (semicolon)

They are POSITIVE;NEGATIVE;ZERO;TEXT, respectively.

If the number is positive, first format is applied,  
else if negative the second,  
else if 0 the third,  
else it's considered as text and the last formatting is applied. 

You don't have to specify all four of them.
If only 1 format is specified it's used for every number.
If only 2 formats are specified, first part is used for positive and zeros, and second part is used for negatives.

If you want to skip some part(s) just use a semicolon for each and define the next part(s) following it(them).

Obviously, your formatting has all 4 sections.

_-* #.##0,00 TL_- for example this is for positives. 

Since your Excel uses Turkish formatting

. (dot) is used as thousands separator and 
, (comma) is used for percentages.  

So if someone wrote 10000 1/2 your formatting will show it as 10.000,50 TL i.e. Ten thousand Turkish Liras and 50 Kuruş.

Other format specifiers in your code have the following meanings:

# Digit placeholder, skips insignificant 0s  
0 Digit placeholder, adds extra insignificant 0s to fill the format  
? Digit placeholder, adds spaces for insignificant 0s to align decimals  
@ Text placeholder  
_ Skips the width of the next character, generally used to align positive numbers with the negatives when negative numbers use a - (minus sign) or parentheses. 
* Repeats the next character to fill the column width

Therefore POSITIVE _-* #.##0,00 TL_-; part of your code can be read as:

  • _- skip the width of minus sign
  • *(space) repeat blanks until column is filled
  • #.##0,00 TL use . as thousands separator, and , as percentage separator, remove them if any 0z are written before the first digit. After the comma take only two digits, remove if more than two used, fill them with 0s if less than two digits used, finally add TL and once again skip the width of -.

Your code already displays - before the negative digits, so if you want to add + before the positive values just add + before the first # in positive part of your code.

share|improve this answer

The official excel how-to article is actually quite good and contains several examples. The article has solutions for about a dozen good cases where you would want to use number formats.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .