## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

**BY JON VON DER HEYDEN 29 JUNE 2012 EXCEL, FEATURE, TUTORIALS
**

Contents

Introduction

Structure

Character Codes

- Text Characters

- Number Characters

- Date Characters

- Time Characters

Conditional Number Formats

Using colors

Examples

- Display a signature strip

- Prefix a number with a single character

- Suffix a number with a text string

- Pad a number with n leading zero‟s

- Right align positive and negative numbers

- Understanding the thousand separator

- Scale a number down by a factor of 1000

- Format percentages

- Display cumulative elapsed time

- Scale a number by a factor of 10

- A quick guide to fractions

- Color coding cells according to value

- Using symbols within number formats

Further Reading

Introduction

Number formatting in Excel is used to change the way a value appears in a cell or range of cells.

Generally speaking number formatting does not actually alter the value, it only changes the way

we see it.

This isn‟t true in all cases, numbers formatted as text are no longer considered as number types

and thus it can be suggested that number formatting can change the value of the cell.

A more accurate method of determining a cells true value is to focus on the value as it appears

in the formula bar.

When one formats a cell one typically uses the Format Cells dialog (Control+1).

There are a variety of predefined formats to choose from in the Category list. The underlying

code to any one of these formats can be seen by selecting the format from the list and then by

immediately proceeding to Custom format. One can define and alter number formats using the

Custom category.

Number formatting can be used in some very creative ways. There are many occasions where

the unaware user constructs complex formulae to display results, or uses conditional formatting,

where an otherwise relatively short number format code would do the same.

Structure

Number formats are separated into four components and each component is separated by a

semi-colon (;). These components are, in order;

positive numbers (+ve)

negative numbers (-ve)

zero‟s

text values

The semi-colon not only acts as a separator for these specific components, but also acts as a

separator for conditional components (but we will get to that later).

One needn‟t complete each component of a number format. Where one or more of these

components are omitted, Excel will make the following assumptions:

1. If only one component is used (i.e. there are no semi-colons present in the code), then all

numbers will be formatted accordingly, regardless of whether or not the number is +ve, -ve

or zero.

2. If two components are used then the 1st component will be used for both +ve numbers and

zero value. The 2nd component is used for -ve numbers.

3. If three components are used then then 1st component will be used for +ve numbers. The

2nd will be used for -ve numbers. The 3rd will be used for zero‟s. Text values will appear as

typed.

Thus, any cell formatted with the following code;

;;;

will appear blank regardless of whether or not the cell contains a number (+ve, -ve or 0) or text.

Every number format component is complete in this code, yet blank, and hence so shall the

appearance of the cell be.

Note: Cell error values (e.g. #N/A) are not affected by number formats.

Character Codes

This section describes what the various characters in a number format code means. These

characters can be categorized as Text, Number, Date and Time.

> Text Characters

Literal Characters; i.e. these characters will appear in the cell according to where in the

number format code they are entered.

$ £ + - /

( ) : ! ^

& ' ~ { }

< > =

Special Characters

Character Remark

""

Displays the literal text between the speech marks.

\

Displays the proceeding [single] character as a literal character.

@

Displays the text entered in the cell.

_

(underscore) Displays a single character [blank] space according to the width of

the proceeding character (i.e. the proceeding character will not be displayed).

*

Displays the proceeding [single] character as many times is required to fill the

width of the cell. This proceeding character will always be taken as a literal,

regardless of what character is actually used.

> Number Characters

Character Remark

#

Displays only significant digits (i.e. the numbers entered into the cell). It does not

display insignificant zero‟s.

0

(zero) Displays both significant digits (i.e. those entered into the cell), but also

displays insignificant zero‟s if a number has fewer digits than there are zero‟s in

the number format code.

.

Decimal separator. The number of proceeding zero‟s will determine how many

decimal places are displayed.

,

Thousands separator if it proceeds #, or scales a number down by a factor of

1000 if it proceeds 0 (zero).

?

Digit placeholder; Displays [blank] spaces for insignificant zero‟s. Also used for

fractions with varying number of digits.

%

Scales a number up by a factor of 100 and suffixes the number with the %

symbol.

E+ or E-

Displays a number in normalized scientific „E‟ notation. “E-” places a minus sign

by -ve exponents. “E+” places a minus sign by -ve exponents and a plus sign

by +ve exponents.

/ Fraction character. See fraction examples later.

Note: The decimal and thousand separator character is determined either by the regional

settings, or the chosen characters defined in Excel‟s advanced options if one chooses to override

the default separators. Be aware therefore that these separators may in fact not be the same as

described in this article.

> Date Characters

Character Remark

d

Displays the day of the month as a number 1-31 (or how many days there

are in the given month) and does not display insignificant zero‟s.

dd

Displays the day of the month as a number 01-31 (or how many days there

are in the given month) and always displays it as a 2-digit number.

ddd Displays the day of the week as Sun-Sat (3 character day)

dddd Displays the day of the week as Sunday-Saturday (complete text)

m

Displays the month as a number 1-12 and does not display insignificant

zero‟s

mm

Displays the month as a number 01-12 and always displays it as a 2-digit

number.

mmm Displays the month as Jan-Dec (3 character month).

mmmm Displays the month as January-December (complete text).

mmmmm Displays the month as J-D (only the first character).

yy Displays the last two digits of the year.

yyyy Displays all four digits of the year.

> Time Characters

Character Remark

h Displays the hour as a number 0-23 and does not display insignificant

zero‟s.

hh Displays the hour as a number 00-23 and always displays it as a 2-digit

number.

[h] or [hh]

Displays the cumulative hours elapsed. The time value could for instance

exceed 24 hours (1 day).

m

Displays the minutes as a number 0-59 and does not display insignificant

zero‟s. Note that this character only represents minutes if used within a

complete time number format code.

mm Displays the minutes as a number 00-59 and always displays it as a 2-digit

number. Note that this character only represents minutes if used within a

complete time number format code.

[m] or [mm] Displays the cumulative minutes elapsed. The time value could for instance

exceed 60 minutes.

s Displays the seconds as a number 0-59 and does not display insignificant

zero‟s.

ss Displays the seconds as a number 00-59 and always displays it as a 2-digit

number.

[s] or [ss] Displays the cumulative seconds elapsed. The time value could for instance

exceed 60 seconds.

am/pm Displays hours based on the 12-hour clock and indicates morning/afternoon

with AM/PM. Note, this is case-sensitive.

Conditional Number Formats

A typical number format already caters for four different conditions. In any single number format

code, we can specify a format for +ve numbers, -ve numbers, zero values and text.

However, one can create even more format conditions. Excel provides an ability to format a

number according to its‟ value.

One does not have to stipulate the exact value for a format; rather one can choose from a whole

range of comparison operators.

Comparison Operators

Character Remark

=

Equals

<>

Does not equal

<

Less than

>

Greater than

<=

Less than or equal to

>=

Greater than or equal to

Whilst the semi-colon (;) is used to delimit the standard four components in a number format,

the semi-colon is also used to delimit conditions.

Conditions must be enclosed in square brackets, e.g:

[>=1000000]0,, \m;[>=1000]0, \k;0

In the exhibit above, the semi-colon no longer delimits the ordinary components (+ve, -ve, zero,

text). The conditional statements now rule the components. In other words, values greater than

or equal to 1 million appear scaled to the nearest one million. If the given figure is not greater

than or equal to 1 million, but is greater than or equal to 1000, then the figure appears scaled to

the nearest one thousand. If neither condition is met then the figure is to be displayed rounded

to the nearest whole number.

Using Colors

Another great feature of number formats is to change the font color of the cell. I use the phrase

“change the font color” loosely, because again cell a values only appear different, the font color

chosen on the ribbon/toolbar will remain unchanged.

Again square brackets [ ] play a role. To format a cell with a color, one either passes the color

name in square brackets, or one passes the word „color‟ and the color index in square brackets.

A typical usage is to format -ve figures in red font. For example:

#,##0.0;[red]-#,##0.0

which is the same as:

#,##0.0;[color 3]-#,##0.0

When formatting color, one has a choice of 8 standard colors by name, or a choice of 56 colors

by color index:

Color Index Color Name Hex Value

1 Black #000000

2 White #FFFFFF

3 Red #FF0000

4 Green #00FF00

5 Blue #0000FF

6 Yellow #FFFF00

7 Magenta #FF00FF

8 Cyan #00FFFF

9 #800000

10 #008000

11 #000080

12 #808000

13 #800080

14 #008080

15 #C0C0C0

16 #808080

17 #9999FF

18 #993366

19 #FFFFCC

20 #CCFFFF

21 #660066

22 #FF8080

23 #0066CC

24 #CCCCFF

25 #000080

26 #FF00FF

27 #FFFF00

28 #00FFFF

29 #800080

30 #800000

31 #008080

32 #0000FF

33 #00CCFF

34 #CCFFFF

35 #CCFFCC

36 #FFFF99

37 #99CCFF

38 #FF99CC

39 #CC99FF

40 #FFCC99

41 #3366FF

42 #33CCCC

43 #99CC00

44 #FFCC00

45 #FF9900

46 #FF6600

47 #666699

48 #969696

49 #003366

50 #339966

51 #003300

52 #333300

53 #993300

54 #993366

55 #333399

56 #333333

Examples

Display a signature strip:

I can‟t think of many opportunities to use the asterisk character, so this is my feeble attempt at

a demonstration. In this exhibit, the solid line for ones signature will always extend the full width

of the cell.

Prefix quarter numbers with ‘Q’:

There may be instances where one has a requirement to prefix or suffix a number with a single

character. The benefit of this is that one may yet use the number in subsequent formulae, since

this still yields a valid number and not text. This display is achieved by using the \ character to

treat the „Q‟ as a literal value.

Suffix a number with a text string:

Format: 0"Days"+

Unformatted Formatted Remark

7 7 Days+

All of these numbers are suffixed with 'Days +'. 'Days' is encapsulated in

speech marks to display the literal term. It is not necessary to

encapsulate the space and '+' in speech marks as both are literal

characters.

14 14 Days+

21 21 Days+

30 30 Days+

This exhibit demonstrates how to include a complete text string using speech marks. The space

and plus symbol do not need to be held within the speech marks as they are treated as a literal

characters regardless. Again, this still returns a valid number and it can be treated as such in

formulae.

Pad a number with n leading zero’s:

Align Positive and Negative numbers:

Format: 0.00_);(0.00)

Unformatted Formatted Remark

-1234.56 (1234.56)

Numbers are displayed rounded to the 2 nearest decimals. Negative numbers are

surrounded by parenthesis ().

1234.56 1234.56

As negative numbers are surrounded by parenthesis, positive numbers accommodate a

blank space the same width as closing parenthesis such that the numbers align (right-

to-left). This is achieved using the underscore character.

This is particularly relevant when enclosing numbers in parenthesis to represent negative values.

In doing so the +ve and -ve figures do not align (left-to-right). One uses underscore character

to create a blank space and the end of the +ve number with the same width as closing

parenthesis.

Understanding thousand separator formats:

It is important to note that the last whole number placeholder is a 0 and not #. Take the figure

0.24.

Given the current format this would be displayed as “0.2″. However, had the format been

#,###.0 (i.e. a # symbol used instead), Excel would only display “.2″. The zero prefix would

not be displayed because it is insignificant.

Even if you make the mistake of using a # symbol, Excel will always make this correction

regardless.

Display figures scaled down by a factor of 1000:

A single comma character is used to scale and round the figure by 1000.

Two commas are used to scale and round the figure by 1000000.

Physically dividing a number by 1000 (or 10000) in order to report a scaled down figure is bad

practice. This method should be chosen instead. Not only is it unnecessary but it also causes

numeric change. Using this number format method does not change the value of the figure, only

its‟ appearance! The accuracy of figures should not be compromised for the sake of reporting!

Format negative percentages:

Some have assumed that because the format cells dialog does not present different formats for

negative percentages that it cannot be done. This demonstrates that percentages are merely

numbers and thus follow the same rules.

Show cumulative time (hours/minutes/seconds):

The typical hour symbol (i.e. h) displays the modulo 24 result. Excel stores time as fractions

such that 1 hour is 1/24, 1 minute is 1/24/60 and 1 second is 1/24/60/60. In this exhibit, the

difference between 24-Jul-2012 18h21 and 23-Jul-2012 14h33 is 1 day 3 hours and 48 minutes.

In Excel this value will be 1.158333333.

Since we are dealing with hours it would be easier to describe the calculation by multiplying

1.58333333 by 24 giving 27.79992 hours. 27.79992 modulo 24 returns 3.79992, which when

divided by 24 yields 0.158333333. Note, the integer component (# of days) has effectively been

truncated, so there is no cumulative result displayed here, the result is merely 3 hours and 48

minutes.

Enclosing the hour symbol in square brackets (i.e. [h]) instructs Excel to display the cumulative

hours of a particular value. Using the current exhibit, we have already established that the

difference between the two date and times is 1.158333333. The cumulative difference is thus 1

whole day (24 hours) plus 0.158333333 (3 hours 48 minutes) resulting in 27 hours 48 minutes.

The same principal applies to minutes (m; [m]) and seconds (s; [s]):

- Demonstrating the difference between two times in minutes.

- Demonstrating the difference between two times in seconds.

Display a number scaled (up or down) by a factor of 10:

If the percentage symbol(%) displays a number scaled up by a factor or 100, and the comma

symbol (,) displays a number scaled down by a factor of 1000, one can therefore use

combinations of these symbols to scale a number by any factor of 10.

The only real downside to the following method is that the percent format always suffixes the

number with a percentage symbol. Whilst there is a work-around, it is hardly ideal! The work

around in the proceeding examples involves forcing a carriage return before the percentage

symbols. This doesn‟t remove the percentage symbols but pushes it down to the next line. Thus,

if wrap text is turned on for the given cell, and the row height is set only to display 1 line, the

percentages appear hidden from view. In these examples, [cr] represents the carriage return.

These can be entered in number formats by pressing Control+J.

The following table demonstrates the format method for scaling by a factor of ten. The number

of decimal places and such is entirely up to you. I have used 12 decimal places for all numbers

only for display purposes. The actual scale display is achieved using the component referred to

as the “modifier”.

Using the number 987.654321

BASE 10

EXPONENT

NUMBER FORMAT MODIFIER FUNCTION FACTOR RESULT

6 #,##0.000000000000[cr]%%% %%%

100

3

1,000,000 987,654,321.000000000000

5 #,##0.000000000000,[cr]%%%% ,%%%%

100

4

÷1000 100,000 98,765,432.100000000000

4 #,##0.000000000000[cr]%% %%

100

2

10,000 9,876,543.210000000000

3 #,##0.000000000000,[cr]%%% ,%%%

100

3

÷1000 1,000 987,654.321000000000

2 #,##0.000000000000[cr]% %

100 100 98,765.432100000000

1 #,##0.000000000000,[cr]%% ,%%

100

2

÷1000 10 9,876.543210000000

0 #,##0.000000000000

1 1 987.654321000000

-1 #.000000000000,[cr]% ,%

100÷1000 0.1 98.765432100000

-2 #.000000000000,,[cr]%% ,,%%

100

2

÷1000

2

0.01 9.876543210000

-3 0.000000000000, ,

1÷1000 0.001 0.987654321000

-4 0.000000000000,,[cr]% ,,%

100÷1000

2

0.0001 0.098765432100

-5 0.000000000000,,,[cr]%% ,,,%%

100

2

÷1000

3

0.00001 0.009876543210

-6 0.000000000000,, ,,

1÷1000

2

0.000001 0.000987654321

There‟s a little quirk one should be aware of, so as to not assume that there is something wrong.

It seems that after applying some of these formats, when one returns to the format dialog the

format code appears different (wrong even). Don‟t worry, the format appearance is correct! It

appears Excel is confused!

A quick guide to fractions

Format of a fraction: #

N

/

D

# Optional whole number

N Numerator (Integer)

D Denominator (non-zero integer)

Proper Fractions: When the numerator is less than the denominator. E.g.:

3

/

4

Improper Fractions: When the numerator is greater than the denominator. E.g.:

4

/

3

Mixed Fractions: When what would otherwise be an improper fraction is represented as the

whole part and the remainder expressed as a proper fraction.

Examples representing 2.235 as a fraction:

Number Format Cell Display Precision as

Displayed Value

Improper Fraction ?/??? 447/200 2.235

Single-digit Mixed

Fraction

# ?/? 2 1/4 2.25

Double-digit Mixed

Fraction

# ?/?? 2 4/17 2.235294

Triple-digit Mixed

Fraction

# ?/??? 2 4/17 2.235

Mixed Fraction as Halves # ?/2 2 2

Mixed Fraction as Thirds # ?/3 2 1/3 2.333333

Mixed Fraction as

Quarters

# ?/4 2 1/4 2.25

Mixed Fraction as Eighths # ?/8 2 1/4 2.25

Mixed Fraction as Tenths # ?/10 2 1/5 2.2

The precision displayed is dependent on the number of denominator digits. Looking at the

exhibit above, 2.235 is displayed as 2

1

/

4

if formatted as single-digit fraction. This equates to

2.25, an imprecision if 0.015. This fraction requires triple-digit format to display full precision.

Fixing the significance of the denominator also affects the precision. The factor is of your own

choosing, note however in the exhibit how neither halves, thirds, quarters, eighths or tenths can

accurately display 2.235 as a fraction.

Color Code cells with RAG status:

Assume the following:

> All values greater than or equal to 100,000 must appear GREEN

> All values greater than or equal to 50,000 must appear AMBER

> All other values must appear RED

Format:

[Color4][>=100000]#,##0;[Color46][>=50000]#,##0;#,##0

The order of the conditions in this format is of the utmost importance. Because Excel is

configured to be efficient, as soon as any condition is met Excel will no longer evaluate the rest

of the format.

Colors applied in number format overrule any font color applied. Thus, should the cell be

formatted as red and none or the conditions met, the font will remain red. As soon as a condition

is met however the cell font color will be inherited from the number format.

Use symbols within number formats

There are two ways of including symbols in your number formats.

1) Copy the symbol and paste it into the number format code

2) Use ALT and type the character code using your number keypad

Here are few:

> Display 1, 2 or 3 stars in a cell according to whether or not the cell value is 1, 2 or 3.

[<2]"«";[<3]"««";"«««";

The chevron character can be typed into a format by holding ALT and typing 0171 on the

numpad.

This format requires that the cell be formatted with Webdings font.

> Prefix text with a bullet point to create a bullet list.

• @

The bullet character can be typed into a format by holding ALT and typing 0149 on the numpad.

> Use the degree symbol to display temperature.

# °C

The bullet character can be typed into a format by holding ALT and typing 0176 on the numpad.

- Engineering units conversion calculation
- sbac lesson plans for the week october13th to 17th 2014
- assignment11
- Numerical Ability test for Indian Bank Clerical Exam 2010
- Yearly Plan Mathematic Year 6
- For Upcoming Bank Exams- Numeric Apptitude
- lesson planner observation one
- Entering Algebra Packet
- 1st Periodical Examination Math 5
- maths program proforma yr 6 t2
- WYMIC 2007
- 4 – Math Homework 03.10-- 03.14.2014 Original & Modified
- AR2 Fractions 1
- 4th grade investigations pacing
- Percentage
- National Insurance Company Ltd (NICL) Aptitude_001 Solved Answer
- Basic College Mathematics 8th Edition Tobey Test Bank
- Aptitude 1
- airtel 5
- Emory
- The Fraction Cheat Sheet (1)
- math obsv
- Aptitude 1
- Ibps Po Clerk Numerical Aptitude Questions
- Indices
- Percentage
- Quantitative Aptitude 2
- Aptitude
- miss kings 5th grade syllabus 2015-2016
- r.s.agarwal Page 51-55

- Quranbook Age Group 9 14
- DMF_Overview.pdf
- Create Bootable USB.txt
- Step by Step DFS
- 1. AX2012_ENUS_DEVIV_TOC.pdf
- MB6-872
- Implementing Budgeting for Microsoft Dynamics AX 2012 Applications AX 2012
- APN Settings for India
- BEx Reporting on 12 Months Rolling Periods using Posting Period (0FISCPER3)
- United Nations Day
- Bw Interview Questions
- Rainwater Harvesting
- ALV List Display
- Roles in BW Projects
- Remodeling Cube in BI

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading