Excel Custom Number FormatsPage cached from http://www.ozgrid.com/Excel/CustomFormats.htm Show 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 from Microsoft� Formatting Codes
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.
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. Microsoft� have a helpful 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. 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
The format dddd can also be used on a date to quickly find out the weekday of a specific date. Times
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: 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.................. There are many other types of custom formats you can use. Don't forget there is also Conditional Formatting What is custom number formatting?A custom Excel number format changes only the visual representation, i.e. how a value is displayed in a cell. The underlying value stored in a cell is not changed. When you are customizing a built-in Excel format, a copy of that format is created. The original number format cannot be changed or deleted.
How does custom number formatting work in Excel?Create a custom format code. On the Home tab, click Number Format. , and then click More Number Formats.. In the Format Cells dialog box, in the Category box, click Custom.. In the Type list, select the number format that you want to customize. ... . In the Type box, make the necessary changes to the selected number format.. What are the types of number formatting?Types of number format. |