Microsoft Excel Training- From Beginner to Expert in 6 Hours/ EXCEL DASHBOARD REPORTS

Ozgrid, Experts in Microsoft Excel Spreadsheets

Excel Custom Number Formats

| | Information Helpful? Why Not Donate.

 

Also see Custom Formats With Symbols | Convert a Numeric Value into English Words | Convert a Currency or Value into English Words

Got any Excel Questions? Free Excel Help

It is very important to understand how cell formats are seen by Excel. Excel see a cells format as having four Sections. These are, from left to right Positive numbers, Negative Numbers, Zero Values and Text values. Each of these Sections are separated by a semi colon (;). If you create a custom number format you do not have to specify all four sections. By this I mean, if you included only two sections, the first section would be used for both positive numbers and zero values, while the second section would be used for negative numbers. If you only used one section, all number types would use that one format. Text is only affected by custom formats when we use all four sections, the text would use the last section.

It is also very important to understand that the formatting of a cells value does not effect its underlying true value. To show this we can type any number into cell A1, then go to Format>Cells-Number-Custom and, using any format as a Starting point, type in "Hello", with the quotation marks, now click OK. Now, while the cell displays the word Hello, it's true value can be seen by selecting the cell and looking in the Formula bar, or by pressing F2. If you were to reference this cell in a formula, e.g. =A1+20 the result cell would also take on the custom format. If we were to reference cell A1 and many other cells that have any standard Excel format, e.g. =SUM(A1:A10) our result cell would still take on the custom format of cell A1. This is an educated guess by Excel that you want the result cell formatted the same as the referenced cell(s). If the referenced cells contain more than one type of format, any custom format will take precedence. So, you must always remember that Excel uses a cells true value and not it's displayed value. This can catch out the unwary if you are calculating cells that are formatted for no, or few, decimal places. For example, enter 1.4 in A1 and 1.4 in A2, format both these cells to show zero decimal places and then place =A1+A2 and the result is 3. Excel does have an option called Precision as displayed, found under Tools>Options-Calculation, but you should be aware that this option will permanently change stored values in cells from full precision (15 digits) to whatever format, including decimal places, is displayed. In other words, once it's been checked and given the OK, there is no turning back.

The default format for any cell is "General". If we enter a number into a cell, Excel will often guess the number format that is most appropriate. For example, if you type in 10%, Excel will format the cell as a percentage. Most often Excel gets this correct, but sometimes we need to change this. One point I will make on this is, when using Format>Cells, resist the temptation of forcing a left, right or centre horizontal format! By default numbers are right aligned and text left aligned. If you leave this alone, you can tell at a glance whether a cell is text or numeric, as in the case of my earlier example where cell A1 appears to hold text, when in fact, it holds a number.

Ok, getting back to the all important Sections that a formatted cell contains. Within these Sections we are able to use Formatting Codes. It is these codes that force Excel to make our data appear how we would like. Let's use a simple Example. Suppose you would like any negative number to appear inside parenthesis, and all numbers, positive, negative or zero, to show two decimal places. The Custom Format we could use is: 0.00_ ;(-0.00). If you also wanted negatives to be red, use: 0.00_ ;[Red](-0.00) Note the use of the square brackets in the Section for negative numbers. This is the Formatting Code that tells Excel to make the number red.

There are many different Formatting Codes that can be used within Sections of a Custom Format. The tables below show these. The Table is

Formatting Codes

Number Code Description
General General number format.
0 (zero) Digit placeholder. This code pads the value with zeros to fill the format.
# Digit placeholder. This code does not display extra zeros.
? Digit placeholder. This code leaves a space for insignificant zeros but does not display them.
. (period) Decimal number.
% Percentage. Microsoft Excel multiplies by 100 and adds the % character.
, (comma) Thousands separator. A comma followed by a placeholder scales the number by a thousand.
E+ E- e+ e- Scientific notation.
Text Code Description
$ - + / ( ) : space These characters are displayed in the number. To display any other character, enclose the character in quotation marks or precede it with a backslash.
\character This code displays the character you specify.

Note Typing !, ^, &, ', ~, {, }, =, <, or > automatically places a backslash in front of the character.
"text" This code displays text.
* This code repeats the next character in the format to fill the column width.

Note Only one asterisk per section of a format is allowed.
_ (underscore) This code skips the width of the next character. This code is commonly used as "_)" (without the quotation marks) to leave space for a closing parenthesis in a positive number format when the negative number format includes parentheses. This allows the values to line up at the decimal point.
@ Text placeholder.
Date Code Description
m Month as a number without leading zeros (1-12)
mm Month as a number with leading zeros (01-12)
mmm Month as an abbreviation (Jan - Dec)
mmmm Unabbreviated Month (January - December)
d Day without leading zeros (1-31)
dd Day with leading zeros (01-31)
ddd Week day as an abbreviation (Sun - Sat)
dddd Unabbreviated week day (Sunday - Saturday)
yy Year as a two-digit number (for example, 96)
yyyy Year as a four-digit number (for example, 1996)
Time Code Description
h Hours as a number without leading zeros (0-23)
hh Hours as a number with leading zeros (00-23)
m Minutes as a number without leading zeros (0-59)
mm Minutes as a number with leading zeros (00-59)
s Seconds as a number without leading zeros (0-59)
ss Seconds as a number with leading zeros (00-59)
AM/PM am/pm Time based on the twelve-hour clock
Miscellaneous Code Description
[BLACK], [BLUE], [CYAN], [GREEN], [MAGENTA], [RED], [WHITE], [YELLOW], [COLOR n] These codes display the characters in the specified colors.

Note n is a value from 1 to 56 and refers to the nth color in the color palette.
[Condition value] Condition may be <, >, =, >=, <=, <> and value may be any number.

Note A number format may contain up to two conditions.

If you do a lot of Custom Formatting you might find it useful to print these tables.

Lets look at the last Formatting Codes, the Comparison Operators. Assume we want our custom number format: 0.00_ ;[Red](-0.00) to only display negative numbers as red font in brackets IF the number is less than -100. For this we could use: 0.00_ ;[Red][<-100](-0.00);0.00 It is the Formatting Codes: [Red][<-100](-0.00) placed in the Section for negative numbers that make this possible.

One format that is often asked for is to display dollar values as words. For this we can use the Custom Format of: 0 "Dollars and" .00 "Cents". This format will force a number entered as 55.25 will be displayed as 55 Dollars and .25 Cents. If you wish to actually convert numbers to dollars and cents, see these two Custom Functions from Microsoft.

  1. Microsoft's Convert a Numeric Value into English Words
  2. Microsoft's Convert a Currency or Value into English Words

Let's look at one more Custom Format where we wish to display the words Low, Average or High along with the number entered. For this we could use: [<11]"Low"* 0;[>20]"High"* 0;"Average"* 0 Note the use of the Formatting Code * This code repeats the next character in the format to fill the column width Meaning all our Low, Average or High text will be forced to the right, while the number will be forced to the left. Workbook you can Download that shows many of the abilities of Custom Formats.

As you are no doubt aware, you can use custom formats to change the way Excel displays Text, Numbers, Dates and Times. What you may not realize is that by changing a cell or cells formatting you are NOT changing it's underlying value. Even if you are counting drugs for a pharmacy or selling generics, you can use this function. So even if you use the custom format option in Excel to force Excel to display the number 20 as "Twenty" you can still use the cell in a calculation.

Below are just some of the custom formats that can be applied to cells in Excel. For all examples you must select the cell or cells and go to Format>Cells>Number>Custom. Then use any one of the predefined formats as a Starting point.

Dates
For all these examples I will use the date: 25/12/2001

To display as: Use the format:
251201 dmy
Tues-12-2001 ddd-m-yyyy
Tuesday 25-12-2001 dddd d-m-yyyy
Tuesday December 25 2001 dddd mmmm d yyyy
Christmas Day "Christmas Day"

The format dddd can also be used on a date to quickly find out the weekday of a specific date.


Times
For all these examples I will use the time 18:30:30

To display as: Use the format:
1830 hhmm
1830 hrs hhmm "hrs"
18 hours and 30 minutes hh "hours and" mm "minutes"
6:30pm h:mm AM/PM

If you are working with times and you want Excel to display hours greater than 24, use the custom format [h]:mm:ss

If you want to display the amount of Minutes that have passed since midnight, use the format [m]. The same applies for Seconds ie; use [s]


Currency

There is not an awful lot more you can do with currency that Excel doesn't allow with it's built in formats. But there is one and that is display the amount as dollars and cents. You can easily display $75.89 as:
75 dollars and 89 cents. To do this use the custom format: 0 "dollars and" .00 "cents"


Text

As with currency there is not an awful lot more you can do with text, but here is one tip. Let's say you want a list of text entries but do not want any blank space after the text. That is you want the entire cell filled. To do this use the custom format: @*. This will fill all the space after the last letter of a word with period (fullstop) so your list will look like:

Dog..................
Mouse..............
Elephant..........

There are many other types of custom formats you can use.

Don't forget there is also Conditional Formatting

Excel Dashboard Reports & Excel Dashboard Charts 50% Off Become an ExcelUser Affiliate & Earn Money

Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over $64.00. ALL purchases totaling over $150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to [email protected] 31 days after purchase date.


Instant Download and Money Back Guarantee on Most Software

Microsoft Excel Training- From Beginner to Expert in 6 Hours/ EXCEL DASHBOARD REPORTS

Excel Trader Package Technical Analysis in Excel With $139.00 of FREE software!

Some of our more popular products are below...
Convert Excel Spreadsheets To Webpages | Trading In Excel | Construction Estimators | Finance Templates & Add-ins Bundle | Code-VBA | Smart-VBA | Print-VBA | Excel Data Manipulation & Analysis | Convert MS Office Applications To...... | Analyzer Excel | Downloader Excel | MSSQL Migration Toolkit | Monte Carlo Add-in | Excel Costing Templates