Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 126

Advancement in MS Excel

OFILAM
EXCEL INTRODUCTION

This topic provides reference information about:

Worksheet and workbook specifications

Calculation specifications

PivotTable report specifications

Worksheet and workbook specifications

Feature Maximum limit


Open workbooks Limited by available memory and
system resources
Worksheet size 65,536 rows by 256 columns
Column width 255 characters
Row height 409 points
Length of cell contents (text) 32,767 characters. Only 1,024 display
in a cell; all 32,767 display in the
formula bar.
Sheets in a workbook Limited by available memory (default is
3 sheets)
Colors in a workbook 56
Cell styles in a workbook 4,000
Named views in a workbook Limited by available memory
Custom number formats Limited by available memory
Names in a workbook Limited by available memory
Windows in a workbook Limited only by system resources
Panes in a window 4
Linked sheets Limited by available memory
Scenarios Limited by available memory; a
summary report shows only the first

Page 1 of 126
Advancement in MS Excel

OFILAM
251 scenarios
Changing cells in a scenario 32
Adjustable cells in Solver 200
Custom functions Limited by available memory
Zoom range 10 percent to 400 percent
Reports Limited by available memory
Sort references 3 in a single sort; unlimited when using
sequential sorts
Undo levels 16
Fields in a data form 32
Custom toolbars in a workbook Limited by available memory
Custom toolbar buttons Limited by available memory

Calculation specifications

Feature Maximum limit


Number precision 15 digits
Largest allowed positive number 9.99999999999999E307
Smallest allowed negative number -9.99999999999999E307
Smallest allowed positive number 1E-307
Largest allowed negative number -1E-307
Length of formula contents 1,024 characters
Iterations 32,767
Worksheet arrays Limited by available memory. Also, arrays
cannot refer to entire columns. For
example, an array cannot refer to the
entire column C:C or to the range
C1:C65536. However, an array can refer
to the range C1:D65535 because the
range is one row short of the maximum
worksheet size and does not include the
entire C or D column.
Selected ranges 2,048

Page 2 of 126
Advancement in MS Excel

OFILAM
Arguments in a function 30
Nested levels of functions 7
Number of available worksheet functions 329
Earliest date allowed for calculation January 1, 1900 (January 1, 1904, if 1904
date system is used)
Latest date allowed for calculation December 31, 9999
Largest amount of time that can be entered 9999:99:99

PivotTable report specifications

Feature Maximum limit


PivotTable reports on a sheet Limited by available memory
Items in a PivotTable report 8,000
Row or column fields in a PivotTable report Limited by available memory
Page fields in a PivotTable report 256 (may be limited by available
memory)
Data fields in a PivotTable report 256
Calculated item formulas in a PivotTable Limited by available memory
report

Page 3 of 126
Advancement in MS Excel

OFILAM
Using Natural Language Formulas

There is another technique for entering formulas, called natural language formulas.
Support for natural language formulas was introduced in Excel 97 but didn't receive the
rave reviews that Microsoft had anticipated. In Excel 2002, support for natural language
formulas is available but is disabled by default. To turn on natural language formulas,
choose Tools > Options to open the Options dialog box. On the Calculation page,
enable the Accept Labels in Formulas check box.

The natural language approach assumes that you know a couple of subtle things about
worksheet design. Make sure that every row and column label is unique. There
shouldn't be two columns or rows labeled Totals, or Excel will simply grab the nearest
one, not necessarily the correct one. The entire label should fit into one cell. If the
column label is Hours Worked, don't put Hours in one cell and Worked in the ceil
underneath. If you do, you can't refer to Hours Worked in a natural language formula
(or anywhere else in Excel).

TIP If you don't want to increment dates, use the Fill commands from the Edit menu.
Select the cell you want to copy and the adjacent destination cells. Choose Edit > Fill
> Down, Right, Up, or Left. Excel swiftly copies the source cell contents into all of
the destination cells. The shortcut keystroke to fill down is Ctrl+D; Ctrl+R fills to the
right.
Using the AutoFill Options

When you fill formulas, there are three choices:

• Copy Cells (the default option) copies the original cell's formula and formatting to the
destination cells.
• Fill Formatting Only copies the original cell's formatting—the same as using the
Format Painter.
• Fill without Formatting fills the formula, but the destination cells retain their original
formatting.

The AutoFill Options button disappears when you choose an option or take other action
in the worksheet.

Filling Series

Excel supports a wide variety of fill options. For example, by selecting one source cell
and filling it you can create the following:

• A linear (n=n+x) numeric series by incrementing the fill value by a specific step
value. For example, if the source cell contains the number 10, you can have Excel add

Page 4 of 126
Advancement in MS Excel

OFILAM
5 to each successive cell to create the series 10, 15, 20, 25, and so on.

• A geometric (n=n*x) numeric series by multiplying the fill by a specific step value.
• A series of days, weekdays, months, or years.

If you initially select more than one cell, you can extend a linear or geometric series
based either on the source cells or the trend in the source cells.

TlP: You can quickly fill a linear series by selecting two cells in the series and then
drag-ging the fill handle. For example, if you select two cells with the values 5 and 10
and then drag the fill handle. Excel fills the following cells with the values 15, 20, 25,
and so on.

Here are the steps to access all the options for the AutoFill feature.

1. Select the source cell or cells and the adjacent destination cells.
2. Choose Edit > Fill > Series to display the Series dialog box
3. Select the series category in the Type area:

Linear For series that increase by adding the same value to each successive cell.

Growth For series that increase geometrically by multiplying by a value.

Date Select Date and select the date interval from the Date Unit area. Your choices
are Day, Weekday, Month, and Year. The Date Unit is only enabled if the source cell
contains a date.

AutoFill Use this for formulas or other series types. Excel determines what series
type to use based on the cells selected. This option is the same as filling by
dragging the fill handle.

4. For Linear or Growth series types, enable the Trend check box or fill in a Step Value
and/or Stop Value:

Trend Select this check box if you selected a range of cells with progressive values.
Excel will determine what the trend is and fill the blank cells accordingly.

Step Value Enter the value you want Excel to use in incrementing the Linear or
Growth series of values. Precede negative values with a minus symbol.

Stop Value Optionally enter the maximum value (or minimum if the Step Value is
negative) allowed in the series.

Page 5 of 126
Advancement in MS Excel

OFILAM
5. Click OK to fill the cells.

6. Select a fill option from the AutoFill Options button menu.

WARNING If you choose Growth and enable the Trend option. Excel calculates the
trend and then adjusts the source cell values to smooth the trend, so the values you
originally selected may also be changed.

Use the Series dialog box to specify parameters for a fill operation.

To quickly fill or copy numbers, formulas, series, and even formats, select the source
cells and then drag using the right mouse button. When you release the right mouse
button, Excel displays the AutoFill shortcut menu. The menu only includes the options
that are relevant to the data in the source cells.

Extended Formulas and Formats

With extended formulas and formats enabled. Excel 2002 automatically does two tilings
when you add new rows to a worksheet:

• Data added to new rows in the worksheet is formatted the same as the preceding
rows.

• Formulas used in each row are copied to new rows.


Excel only extends formats and formulas that are used in three of the five rows imme-
diately above the new rows.

Extension is turned on by default. To turn it off (or turn ft back on), choose Tools >
Options and click the Extend List Formats and Formulas check box on the Edit tab.

Page 6 of 126
Advancement in MS Excel

OFILAM

RELATIVE AND ABSOLUTE CELL REFERENCES


When you copy a formula from one cell to another, Excel automatically adjusts each
cell reference in the formula. If, for example, the formula in cell JI5 is =H15+I15 and
you copy the formula to J16, it is automatically adjusted to =H16+I16. In this example
H15 and I15 are relative cell references—references made by simply clicking in thee or
typing a cell address when creating a formula. The relative change from one row (15)
to another (16) is reflected in the formula when the formula copies: The row the cells
are increased by one.

NOTE When copying cells in Excel, it doesn't matter if you copy and paste, drag-an
drop, or drag the fill handle. Excel treats formulas the same way, regardless of the co
method you employ You will, however, see different choices on the AutoFill Options h
ton menu for the fill operation.

Most of the time, this is exactly what you want Excel to do. When you copy a formula
from one column to another, you want Excel to adjust the column reference copy from
one row to another should result in a change in the row numbers used! the formula.
However, there are exceptions.

EXPERT TIP An Excel worksheet has two layers: a value layer, which is displayed in
the worksheet window, and an underlying formula layer. When you select a worksheet
cell, the cell's formula layer is displayed in the formula bar. You can toggle between the
two layers by holding the Control button and pressing the accent key (') to the left of
the number 1.

Absolute Cell References

You can instruct Excel not to change the reference to E12 by making it an absolute cell
reference. Absolute cell references are preceded with dollar signs: $E$12. The dollar
signs "lock in" the cell reference so Excel doesn't change it if you fill or copy the for -
mula to another cell.

The dollar sign in front of the E instructs Excel not to change the column; the dol lar
sign in front of the 12 locks in the row. So as you fill the formula to the other cities, E6
will change to E7, E8, and E9, but E12 will always be E12.

You create the absolute cell reference in the original formula. If you never intend to fill
or copy a formula, you don't need to use absolute references, and they won't fix a
formula that doesn't work correctly to begin with. (The original formula for Las Vegas in
F6 worked just fine.) If you are typing the formula, just precede the column and row
addresses with a $. You can also create the absolute cell reference using the F4 key, as

Page 7 of 126
Advancement in MS Excel

OFILAM
you will see in the following steps.

TIP Another way to handle this situation is by naming cell E12 (QtrTotal would be a
good name) and using the name in the formula in F6. Names are always absolute, so
when the formula is filled, the name will always refer to E12. See Chapter 4, "Using
Names and External References," for more on naming ranges.

Follow these steps to create a formula that includes an absolute cell


reference:

1. Place the cell pointer where you want the results of the formula to appear.

2. Begin entering the formula. After you click on the cell that should not change when
the formula is copied, press the F4 key once to add $ to the row and col umn of the cell
reference.

3. When the formula is complete, press Enter or click the green check mark in the
formula bar.
When you fill the formula to the appropriate cells, the absolute cell reference will not
change.

Mixed Cell References

You can also create a mixed reference, making part of a cell address absolute and part
relative, by locking in either the column or the row. Use mixed references when you
want to copy a formula down and across to have a reference change relatively in One
direction but not in the other.

For example, E$5 will remain E$5 when copied down because the row reference is
absolute, but it can change to F$5, G$5, and so on when copied across because the
column reference is relative.

TIP The Absolute key (F4) is a four-way toggle. The first time you press it, it locks both
the column and row: SEJ12. Press it again, and only the row is locked: ES12. The third
time you press the Absolute key, the column is locked: $E12. Press it a fourth time, and
both row and column are relative: El 2.

Page 8 of 126
Advancement in MS Excel

OFILAM
Formatting Numbers
Excel lets you present numbers in a variety of formats. Formatting can identify numbers
as currency, percentages, or other specific types and makes numbers easier to read by
aligning decimal points. You format selected cells with the Formatting toolbar or the
Format- Cells dialog box, which opens from the Format menu or the shortcut menu.

NOTE Cells with formulas are formatted automatically. The formula cell picks up the
formatting of the first cell referenced in the formula, unless that cell is formatted as a
percentage.

When you format a number, you change its appearance in the worksheet, not its value.
For example, if you format the number 10.575 for two decimal places, the number is
displayed in the cell as 10.58. If you then multiply the cell by 10, the result is 105.75,
not 105.80. To view the unformatted contents of a cell, click the cell and look at the
formula bar. The number entered in the cell appears in the formula bar exactly as
entered regardless of the format that has been applied to the cell.

TIP If you're going to multiply formatted numbers (for example, in an order, payroll, or
inventory system) use the ROUND function. For more information on the rounding func-
tions, see Chapter 8, "Using Financial Functions." –

Using the Format Cells Dialog Box

The Format Cells dialog box has more numeric formats that don't appear on the For-
matting toolbar. With the cells you wish to format selected, open the dialog box in any
of these three ways: choose Format > Cells from the menu bar, press Ctrl+1, or right-
click in the selection and choose Format Cells from the shortcut menu.

The Format Cells dialog box has separate tabs for Number, Alignment, Font, Border,
Patterns, and Protection. Figure 2.8 shows the Number tab, which includes a list of
format categories (see Table 2.4) and controls for the number of decimal places, the
separator for numbers over 1,000, and the treatment of negative numbers. Choose a
category, and then fill in the other options.

The Format Cells dialog box has options that don't appear on the toolbars.

Page 9 of 126
Advancement in MS Excel

OFILAM

Category Description

General The default format.


Number Like General, but with set decimal places, a thousands
separator, and formatting for negative numbers.
Currency Numbers are preceded with a dollar sign immediately
before the first digit. Zero values are displayed.

Accounting Dollar signs and decimal points line up. Zero values are
shown as dashes.
Percentage Displays numbers as a percentage. Numbers are
Scientific displayed in scientific notation: for example, 1.01 E+03.

TIP If you point to the button on the Formatting toolbar with the dollar symbol, the
ScreenTip indicates it is the Currency Style button. However, when you apply this
button's format. Excel applies the Accounting format, with dashes for zeros and the
dollar signs lined up. Microsoft has decided not to fix this discrepancy.

The Format Cells dialog box includes six more specialized formatting categories:
• Date
• Time
• Fraction
• Text
• Special
• Custom

Date and Time Formats

Microsoft Excel stores dates as sequential serial values beginning with 1 for January 1,
1900. Times are stored as fractions of a day. Because dates and times are numbers,
you can use dates in formulas to determine, for example, the number of hours an
employee worked by subtracting the starting time from the ending time.

Date and time formats are regional; in the United States, the most common date
format is month, followed by day, followed by year: 12/31/2002. In Europe, the month
and day are reversed: 31/12/2002. When you select Date or Time from the Category

list in the Format Cells dialog box, you can choose a Locale from the drop-down list
(see Figure 2.9) to choose from formats appropriate for a location to present (for
example, dates and times in a travel itinerary in the appropriate format for each stop).

Page 10 of 126
Advancement in MS Excel

OFILAM

Select a locale to see a list of appropriate date or time formats.

The asterisked formats on the Date and Time lists (and the default formats) change
based on the Locale selected in the Windows Control Panel Regional Options (Start >
Settings > Control Panel). If, for example, you change the Locale from English to
Spanish (Argentina) in the Control Panel, the date formatted as Monday, January 1,
2001 using the asterisked long date format is changed to Lunes, 01 de Enero de 2001.
If you use the asterisked formats, worksheet dates are "translated" into the language
set in Windows. Choose a nonasterisked format if you don't want the formats to change
based on operating system settings.

Date Systems Excel supports both the Windows 1900 date system and the 1904 date
system used on the Mac. The default date system for Microsoft Excel for Windows is
1900. To use the 1904 date system, choose Tools > Options to open the Options dialog
box. On the Calculation tab, enable the 1904 Date System check box.

If you open an Excel workbook created on a Mac, Excel automatically switches to the
1904 date system so that dates are correctly represented in the workbook.

Whether you use the default 1900 date system or the 1904 date system, you should
enter all four digits of the year. If you use the mm/dd/yy format, typing only two digits
for the year. Excel assigns the first two digits of the year. How the date is interpreted
depends on your operating system. With Windows NT, Excel interprets 00 through 29
as twenty-first century dates: 2000-2029. Years entered as 30 through 99 are assigned
to the twentieth century: 1930-1999.

Page 11 of 126
Advancement in MS Excel

OFILAM
Trouble shooting

In Windows 98 or Windows 2000, Excel relies on the Regional Options in the Windows
Control Panel. Use the spin box control to set the ending year for the range of years
that Excel should use when converting two-digit years to four-digit years.

While you're in the Regional Options dialog box, you can set the default date format to
display four-digit years. In the Short Date Format list, select any format that ends in
yyyy.

Fraction Formats
Choose from formats based on either the number of digits to display in the divisor (1,
2, or 3) or the fractional unit (halves, quarters, tenths, and so on).

Special and Text Formats


Unlike the other formatting categories, Special and Text change the underlying value of
the number. If you format a number with Special or Text, you will not be able to use
the number in mathematical operations unless you first reformat the cells with some
other format.

There are special formats for each locale. Special formats convert numbers to text.
Excel includes formats for different types of numbers that aren't mathematical values:

Page 12 of 126
Advancement in MS Excel

OFILAM
zip codes, zip code + 4, phone numbers, and social security numbers.

Text formats change a number entered in the cell to text without adding other for-
matting. This is useful for numeric labels that may include leading zeros, such as
employee ID numbers. All the regular numeric formats strip off leading zeros.

You must apply the Text format before entering the cell's contents: numbers entered
and later formatted as Text are always treated as numbers.

Tl P If you only have a few numbers that need to be treated as text, you can enter
them manually. Simply type an apostrophe 0 before the number, and Excel treats the
number as text. Be aware, however, that you may have problems linking or importing
these apostrophized numbers into other applications, such as Access.

Custom Formats

If you can't find the format you need on the list, create a custom format. We've found a
number of uses for custom formats, including the following:

• For a real estate appraisal firm, a format that includes the text /sq ft: $15.51/ sq»ft

• Formats for a warehouse worksheet that included the text /pal ette and /box

• A format that omits the last three digits of a number to present budget figures in
thousands of dollars (1,500,000 as 1,500)or omits the last six digits for figures in
millions

• A format that appends the text Net Gai n to a positive number and (Net Loss) to a
negative number for use in income statements

• A format that hides zero values in a worksheet by changing the font color to white

• A format that replaces any text entry with N/A

Each of the codes shown in Table 2.5 is a placeholder for a digit or a character. You
string together a number of placeholders to create a format. If a number has more dig-
its to the right of the decimal than there are placeholders, the number is rounded so it
fits in the number of placeholders. For example, if the format has two placeholders to
the right of the decimal, 5.988 is rounded to 5.99.

Page 13 of 126
Advancement in MS Excel

OFILAM

Code Use Example


# Displays significant digits ###.## formats 3.50 as 3.5 and
3.977 as 3.98
0 Displays all digits; placeholders to the ##0.00 formats 3.5 as 3.50 and
right of the decimal are filled with 57.1 as 57.10
trailing zeros if required
? Displays significant digits and aligns ???.?? displays 3.50 as 3.5, 57.10
decimal or slash placeholders as 57.1, and 3.977 as 3.98, and
aligns decimals
/. Displays a number as a fraction # ??/?? displays 7.5 as 7 1/2
’ Thousands separator, also used to ##,### displays 99999 as
Format numbers as if they were 99,999, ##, displays 9,000 as 9
Divided by a thousand or a million ##,, displays 9,000,000 as 9
() Parentheses, used to format negative (##,###) formats -99999 as
numbers (99,999)
- Hyphen, used to place a hyphen in a 000-000 formats 123456 as 123-
number 456
““ Indicates a text string. ### "/per hour" formats 100 as
100/per hour

To create a custom format, follow these steps:

1. Select the cells you want to format.


2. Choose Format > Cells to open the Format Cells dialog box.
3. On the Number tab, choose the format that most closely resembles the format you
want to create.
4. Select Custom from the Category list.

5. Edit the codes in the Type text box (see Tables 2.5 and 2.6),
6. Click OK to create and apply the format.

You can skip step 3. Just select the format in the Type text box and begin typing a
format from scratch. As you enter a format, the sample reflects your changes. Click OK
to create the format.

Custom formats are saved in the workbook, so you don't need to recreate a format that
you've used elsewhere in the workbook. To delete a custom format, select it from the
Type list, and then click the Delete button in the Format Cells dialog box.

NOTE Excel differentiates between significant digits and insignificant digits. A signifi-
cant digit is part of a number's "real value." In the value 3.70, the 3 and 7 are

Page 14 of 126
Advancement in MS Excel

OFILAM
significant the zero is an insignificant digit, because removing it doesn't change the real
value of the number. Only zeros.can be insignificant. Insignificant zeros after the
decimal are called trailing zeros. Different placeholders display or hide insignificant
zeros.

A number format includes up to four sections separated by semicolons. Each of the


sections is composed of the codes listed in Table 2.5. The first section is applied to
positive numbers and the second to negative numbers. The third section is applied to
only one value: zero. The fourth section is used to specify a format for text.

This is the format that's used when you apply the Accounting format with two decimal
places:

_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)


When Excel applies this format

• _( $* #, ##0.00_) is used for positive numbers.


• _( S* (#, ##0.00) is used for negative numbers.
• _( $* " -" ??_) is used for the value 0.
• _(9_) is used to format text entries.

You don't need to create all four sections of a format. If there's only one section, it is
applied to all numbers. If you want to skip a section (to create, for example, a for mat
that includes only sections for numbers and text), be sure to include the semicolons
that let Excel know what each section is used for. For example, the format #,##0.00;;;
"NA" formats positive numbers using the first format, negative and zero values using
the defaults, and displays the text "NA" if there's a text entry in the cell.

Entering Currency Symbols Enter the ''ollowing symbols in a custom format from the
numeric keypad while pressing the Alt key:

Symbol Shortcut
£ Alt+0163
¥ Alt+0165

Alt+0128

Using Color in a Custom Format You can add one of eight colors to a format. The
colors come from the two default RGB color palettes used in old PC applications, so for
some of us, these colors are a trip down memory lane. Don't smack your monitor—
that's really what green used to look like. Type the name of the color in brackets at the
beginning of the format: [BLUE], [GREEN], [RED], [MAGENTA], [CYAN], [YELLOW],
[BLACK], or [WHITE].

Page 15 of 126
Advancement in MS Excel

OFILAM
TIP There are a couple of approaches to conditional formatting within a custom
format. The format [BLUE] ##; [RED]##; [WHITE] ## will display blue positive
numbers, red negative numbers, and white zeros. On a white background, this
makes zeros disappear. A fourth section can be used for text that appears in the cell
(see the "Codes for Text" section later in this chapter)

Conditional Formatting in Number Formats You can enter a condition in brackets,


followed by the two formats to be used based on whether the condition is true or
false. A common use for a conditional custom format is formatting zip codes when
some have nine digits and others have five. The condition [>99999] will be true for
nine-digit zip codes, so the format [>99999] 00000-0000; 00000 will format both
nine-digit and five-digit zip codes correctly, including leading zeros.

NOTE You can apply conditional formatting without creating a custom format. See
the "Conditional Formatting" section in Chapter 12.

Codes for Dates and Times Use the format codes shown in Table to create date and
time formats. The m code is used for both months and minutes. Excel treats the m
as a month code unless it appears directly after a code for hours or before a code
for seconds.

m Months as ## Formats January as 1


and December as 12
mm Months as 00 Formats January as
01 and December as
12
mmm Months as three- Formats January as
letter abbreviation Jan
mmmm Month name Formats Jan as
spelled out January
nnmmmm Month's first letter Formats January as J
December as D
d Days as ## Formats 1 as 1 and
31 as 31
dd Days as 00 Formats 1 as 01 and
31 as 31
ddd Days as weekday Formats 1/1/99 as Fri
abbreviation
dddd Days as weekday Formats 1/1/99 as
Friday
yy Years as 00 Formats 1999 as 99
yyyy Years as 0000 Formats 1/1/99 as
1999

Page 16 of 126
Advancement in MS Excel

OFILAM
h, m, s Hours, minutes, Formats 3 as 3
and seconds as ##
hh, mm, ss Hours, minutes, Format 3 as 03
and seconds as 00
AM/PM 12-hour clock, h AM/PM formats
uppercase 3.00 AM as 3 AM;
h:mm AM/PM format
3 AM as 3.00 AM
am/pm 12-hour clock, hh am/pm formats 3
lowercase as 03 am; h am/pm
formats 3:00 AM as 3
am
a/p 12-hour clock,
short form

Formats January as 1 and


December as 12
Formats January as 01 and
December as 12
Formats January as Jan
Formats Jan as January
Formats January as J and December
as D
Formats 1 as 1 and 31 as 31

Formats 1 as 01 and 31 as 31
Formats 1/1/99 as Fri
Formats 1/1/99 as Friday
Formats 1999 as 99
Formats 1/1/99 as 1999
Formats 3 as 3
Formats 3 as 03
h AM/PM formats 3:00 AM as 3 AM;
n:mm AM/PM format 3 AM as 3:00 AM
hh am/pm formats 3 as 03 am; h am/pm formats 3:00 AM as 3 am
hh:mm a/p formats 3:00 AM as 3:00 a

Page 17 of 126
Advancement in MS Excel

OFILAM

If you don't include one of the versions of am/pm. Excel bases time on the 24-hour
clock.

The Gregorian calendar, the calendar used in the western hemisphere, replaced the
Julian calendar in the fourteenth century. There are other calendars: Buddhist, used
in Thailand, and Hijri, used in the Middle East. To format a date as a Gregorian date
regardless of Locale selected in the Regional Options dialog box, type Bl at the
beginning of the custom date format. If Arabic editing is enabled, type B2 before the
format code to display the date as a Hijri date. For Buddhist dates, create the
custom format d/m/bbbb.

Codes for Text To include text along with a number in a cell, put quotes around
the text string or precede the text with a backslash (\). If you want to include a for-
mat for text entered in a cell, make it the final section in your format. The @ symbol
stands for any text typed in the cell, so [BLUE]® or simply [BLUE] formats text in
the cell in blue. If you don't include a text format, text entered in the cell is
formatted according to the defaults or the formatting applied with the toolbar and
Format Cells dialog box.

Spacing Codes You'll use spacing codes for two reasons: alignment and filling. In
some formats, negative numbers are surrounded by parentheses. If you use
parentheses in a custom format, you need to add a space to the end of the positive
format that will line up with the right parenthesis in a negative value. (This keeps
the decimal points lined up.) To create a one-character space in a format, include an
underscore:
##,##o.oo_. .

You can fill any empty space in a cell by entering an asterisk (*) and then a fill
character in the number format. For example, the accounting format begins with an
underscore and a dollar sign, followed by an asterisk and a space before the digit
placeholders: _$* #,##0.00. This ensures that the dollar sign is one space from the
left edge of the cell, and that all the room between the dollar sign and digits is filled
with spaces.

Page 18 of 126
Advancement in MS Excel

OFILAM
PASTE SPECIAL
With Paste Special, you can do the following:

• Paste formats including or omitting borders


• Paste comments
• Quickly update a range of values by adding, subtracting, dividing or multiplying
them by another number
• Transpose columns of data to rows of data and vice versa
• Convert a formula to a value
• Paste a column of data while omitting blank cells

While you can paste any of the items from the Office Clipboard by choosing Paste
from the item's menu in the task pane, Paste Special only pastes the last item cut or
copied. Even if you delete newer items from the clipboard, Paste Special retairs and
pastes the last item cut or copied. If the last item was cut or copied from Excel,
choosing Edit > Paste Special or right-clicking and choosing Paste Special opens the
Paste Special dialog box as shown in Figure 3.8. There are two sets of options
buttons and two check boxes in the Paste Special dialog box. You can set both a
Paste Option and an Operation option and enable either or both check boxes before
clicking OK or Paste Link to paste.

Page 19 of 126
Advancement in MS Excel

OFILAM

Page 20 of 126
Advancement in MS Excel

OFILAM

Page 23 of 126
Advancement in MS Excel

OFILAM

Paste Special Paste

Use the Paste options in the Paste Special dialog box to paste all or part of the
information from or about a cell, as shown in Table

Option Result
All The same results as Paste
Formulas Pastes the formula, but retains the destination formatting
Comments Pastes comments from the cut or copied cells for
worksheet documentation

Page 24 of 126
Advancement in MS Excel

OFILAM

Values Pastes the result of a calculation rather than the formula


Formats Pastes the format only; like using the Format painter.
Validation Pastes data validation settings, input messages, and error
alerts
All Except Borders Pastes the contents and formatting other than borders so
you can reuse a bordered formula (for example, a grand
total) elsewhere in the row or column
Column Widths Sets the column widths to match those of the copied
columns;
Formulas and Number you can also do this using the Format Painter
Formats
Values and Number Formats Converts formulas to values and pastes values and
number formats only

The two values options, Values and Values and Number Formats, are used to convert

Page 25 of 126
Advancement in MS Excel

OFILAM

formulas to values so you can delete the cells used in the formula and retain the
results.

Calculating Without Formulas with Paste Special

Use the Operations options to perform a calculation on a range of data. For example,
you can multiply numbers by -1 to convert negative numbers to positive numbers,
decrease every expense line in a budget by 20 percent, or multiply the ticket quantities
1 through 10 by the single-ticket price to calculate the total price for tickets at each
quantity. To perform an operation follow these steps:

1. Copy the value (single cell) that you want to add, subtract, multiply, or divide a
range of cells by.
2. Select the range of cells you want to perform the operation on.
3. Choose Edit > Paste Special or right-click and choose Paste Special from the shortcut
menu.

Page 26 of 126
Advancement in MS Excel

OFILAM

4. Choose the Values option and the math operation.


5. Click OK to apply the operation to the selected cells.

Transposing Data with Paste Special

Transposition rotates the pasted data 90 degrees, turning rows into columns and
columns into rows. Transposition is frequently used to convert a table of data entered
in columns into row-based data so it can be sorted, filtered, and subtotaled using
Excel's database tools. In Figure 3.10, we received an employee worksheet with one
employee per column (cells A3J7). We selected the data and used the Paste Special
transpose option to paste the data as shown in the figure.

Page 27 of 126
Advancement in MS Excel

OFILAM
TIP If you frequently find yourself adding sheets to workbooks,
increase the default number of sheets in a new book. Select Tools >
Options from the menu bar, and change the Sheets in New
Workbook setting on the General page of the Options dialog box.

Page 28 of 126
A
O
N
A









Page
29 of
126
A
O
T



1.
2
3

U
T

1
2
3
4

Page
30 of
126
A
O

Page
31 of
126
Advancement in MS Excel

OFILAM

Editing a name or the range referred to by a name is equally easy. First, choose Insert > Name > Define to open the Define Name dialog box.

• To change the name used to refer to a range of cells, select the name from the list of named ranges. Then select the name in the Names in Workbook text box, overtype the old name with the new name, and click Add. Select and delete the old name.

• To change the cells referred to by a name, select the name from the list of names. Select the range in the Refers To text box. Select the correct range of cells in the worksheet (you can click the Collapse button in the Refers To text box to hide the dialog box), and then click Add.
.
To delete a name, select the name from the Names in Workbook list and click the Delete button.

Page 32 of 126
Advancement in MS Excel

OFILAM

TIP Names are very persistent. When you delete a sheet that contains named ranges,
Excel does not delete the names. They won't appear on the Name box drop-down list,
but they're still hanging around. Open the Define Names dialog box to delete the
names.

Page 33 of 126
Advancement in MS Excel

OFILAM
Creating Names from a Row or Column

You can define a group of labels in a row or a column at one time using the
Create Names dialog box, shown in Figure.

1. Select the range to be named. Include the cells you want to use as names as
either the top or bottom row, or the first or last column selected.

2. Choose Insert > Name > Create from the menu bar to open the Create Names
dialog box.

3. In the Create Names In area, select the row(s), Top or Bottom, or column(s),
Left or Right, that contains the labels you want to use to name the selected
range.

4. Click OK to apply the names and close the dialog box.

How Excel Creates Range Names from Labels

Excel edits text as needed to make valid names. Excel uses these standards to
generate names from labels or other text:

• If the label for a column or row contains spaces, Excel will replace the space
with an underscore: Interest_Rate.

• If the cell contents begin with a number, like 8-Mar or 4 bags. Excel will add an
underscore to the beginning of the name: _8-Mar or _4_bags.

• Excel will not create a name for a cell that contains only a number (like 1998,
78, or 1254.50). Excel will let you go through the motions, but it won't create
the names.

TIP After creating names, open the Define Names dialog box and create new
names that do not include underscores within the name.

Using Names

After you've defined a range, you can enter the range name anywhere a regular
cell reference is valid. For example, you can enter the name of a range as an
argument for a function: =SUM(Totals) to add the cells in the range named
Totals. To insert a name in a formula, type the name or choose Insert > Name >
Paste from the menu to open the Paste Names dialog box.

Page 34 of 126
Advancement in MS Excel

OFILAM

Select th& name from the list and click OK to paste the name into the formula. If
you select the named cells or range, Excel will change the cell reference to the
range name. If you fill or copy the formula that contains a name, the name is not
changed in the pasted or filled cells. In Excel, range names are always absolute.

TIP If you don't want Excel to convert the cell or range address to a name, type
the cell * • address rather than selecting the cells for the formula.

Names also serve a valuable navigation function in large workbooks and complex
worksheets. To move to and select a named range anywhere in a workbook,
click the drop-down arrow in the Name box and select the name from the list.

Names created from column and row labels can be used to refer to specific cells
at the intersection of the named row and column. In the Undiscovered Country
worksheet shown in Figure 4.5, the range A6:E6 is named LasVegas. June refers
to D6:D10. The formula =LasVegas June will return the value (41) at the
intersection of the two ranges: cell D6.

Page 35 of 126
Advancement in MS Excel

OFILAM

A formula in this worksheet uses names to return the value at the intersection of
row 6 (LasVegas) and column D (June).

TIP To list all the names in the active workbook and the cells they refer to, go to
an ' empty area of a worksheet and open the Paste Name dialog box. Click the
Paste List button.

Stretching Names to the Max


Names are incredibly versatile. In this section, we'll create less traditional names;

External Name* Names that refer to ranges in other workbooks.

3D Range Names Names that cross multiple sheets.

Local Names Names that repeat within a book.

Constant Names Names that refer to values rather than ranges.

Creating Names That Refer to Other Workbooks

You can use the Define Name dialog box to create names that refer to cells in
any open workbook. For example, you may want to refer to a workbook that
includes sales and expense totals for the third quarter. Rather than copy or link
to these figures in your annual sales workbook, you can create names (Total 3
rdSal es, Total 3 rd-Expenses) that refer to them. When you refer to a cell in
another workbook, the reference is an external reference. You name external
ranges as you would name ranges in the current workbook, then use the names
as external references in formulas. To name a range in another workbook for use
in the current workbook, follow
these steps:

Page 36 of 126
Advancement in MS Excel

OFILAM

1. Open both workbooks.


2. Switch to the workbook where you want to create the name.
3. Open the Define Names dialog box (Insert > Name > Define).
4. Type a name for the reference in the Names in Workbook text box.
5. Click in the Refers To text box. Click the Collapse button.
6. Use the Window menu to switch to the workbook that contains the range you
want to name.
7. Select the range you want to name.
8. Click the Expand button to expand the Define Names dialog box.
9. Click Add to create the range name.
External ranges don't appear on the Names drop-down list in the active
workbook, but you can use them in formulas as you would internal named
ranges. Type the range name or choose Insert > Name > Paste to paste the
named range into a formula.

There is a potential downside—if the other workbook is deleted, moved, or


renamed, Excel won't be able to find the named range.

Creating Names That Span Worksheets

A 3D name refers to the same cell in more than one worksheet in a book. For
example, in a budget workbook the total sales figure is always in cell D87 of
each worksheet. You can create a 3D name that refers to D87 across multiple
worksheets. Follow these steps to define a 3D range name:

1. Choose Insert > Name > Define from the menu bar.
2. In the Names in Workbook text box, type the range name.
3. Delete any reference in the Refers To text box, and type =.
4. Click the tab for the first worksheet you want to reference, hold Shift, and
select the tab for the last worksheet to be referenced.
5. Select the cell or range to be named.
6. Click Add to add the name, and click OK to close the dialog box.

While 3D range names have a limited navigation use, they're very useful in sum-
mary formulas for workbooks that contain a series of periodic worksheets.

Creating the Same Name in Multiple Worksheets

By default, names have workbook scope: they're available anywhere in the

Page 37 of 126
Advancement in MS Excel

OFILAM
workbook. If, for example, you create the name LasVegas on Sheetl, you can
refer to LasVegas in a formula on SheetZ. Therefore, you can't also name a
range of cells on Sheet2 LasVegas. It takes only a bit more effort to create
names with worksheet scope, allowing you to use, for example, the name
LasVegas to describe a similar range of cells that appears on all four sheets in a
workbook. Names with worksheet (local) scope are called local names or
worksheet names.

Follow these steps to define a name with local scope:

1. Select the worksheet that you want to create the name in.
2. Select the cells you want to name.
3. Choose Insert > Name > Define to open the Define Name dialog box.
4. In the Names in Workbook text box, enter the sheet name, an exclamation
point, and the range name. For example, to name a range LasVegas on
Sheetl, enter =Sheetl! LasVegas. If the sheet name includes a space, put
single quote marks around the sheet name: =' Jan Sal es'! LasVegas.
5. Click Add.
6. Close the Define Name dialog box.

You can have global and local names that are the same. In our workbook, we
have three similarly named ranges:

• A range in the Summary worksheet named LasVegas


• A range in the 1st Qtr Sales worksheet named ' 1st Qtr Sal es'! LasVegas
• A range in the 2nd Qtr Sales worksheet named '2nd Qtr Sales'! LasVegas

The range name LasVegas appears on the drop-down list in the Name box only
once. That single reference always refers to the appropriate named range: the
local name if there is one or the global name if there is no local name. For
example, when the 1st Qtr Sales or 2nd Qtr Sales sheets are active, LasVegas
refers to the local name. Select LasVegas from the Names list, and the locally
named range is selected. When any other worksheet is selected, choose
LasVegas from the Names list and Excel switches to the Summary worksheet and
selects the global LasVegas range.

TIP If you copy a sheet that includes a named range. Excel creates a local
version of the same name, resulting in extra local names. The extra names can
create problems in formulas later. Switch to the copied worksheet and open the
Define Names dialog box to delete the extra names.

Local names allow you to create brief names that still work in formulas. In our
workbook, we have three choices: use names only on one sheet, use local
names, or get creative with the names we create (using names like LasVegasQl,

Page 38 of 126
Advancement in MS Excel

OFILAM
LasVegasQ2, and so on). Local names are much easier to work with.

If you type a range name into a formula or use the Paste Name dialog box, the
same rules apply. However, you can use a local name in a formula in other
worksheets if you enter the entire name, including the sheet name. For example,
Sheetl!LasVegas always refers to the LasVegas-named range on worksheet
Sheetl.

NOTE When you list range names by clicking Paste List in the Paste Name dialog
box, the list excludes local names except those on the active sheet.

Using Names to Store Constants

Most users know about naming cells, but don't realize that you can use the
Define Name box to name constants as well as cell ranges. Why is this useful?
Rather than entering values for fixed items like markups, interest rates, or hourly
rates in worksheet cells where they're visible and accessible, you can enter them
as named items where they're accessible but less visible.

To create a named constant, choose Insert > Name > Define to open the Define
Names dialog box. Enter a name in the Named in Workbook text box. In the
Refers To text box, type an and then the constant. Click Add, In Figure 4,6,
we're creating a constant named Markup that's 15%.

Named constants can include calculations. For example, -10% * 45 is a valid


Refers To entry, which makes names a great way to embed business logic and
rules in a worksheet.

One more advantage to named constants: if we need to change the markup


used throughout a workbook, we only need to change it in one place.

Use the Define Name dialog box to create constants that can be used
throughout a workbook.

Page 39 of 126
Advancement in MS Excel

OFILAM

Using Names to Store User-Defined Functions Let's take names one step further. You can include functions in named ranges. For
example, the following formula takes the year entered by a user in cell B3 on Sheet2 and returns the date for the first day of the year:
=DATE(Sheet2! $B$3,1,1). You can enter this formula in the Refers To text box and name it YearStart or something similar, then use it
in a formula wherever you need to in the workbook instead of performing the calculation each time you need it. The date and text
functions are discussed in Chapter 6, "Manipulating Text and Dates."

EXPERT TIP There's an easy trick you can use to view the named ranges in a worksheet: change the zoom to 25%, or any zoom less
than 40%, and Excel displays the range names in the worksheet like watermarks.

Linking to Other Data

A link is a reference to a cell or range in another workbook. Links are commonly used to avoid double-entering workbook information.
For example, say you work in a company where departments are responsible for their own budgets. As the time to finalize the coming
year's budget approaches, each manager is working furiously on his or her budget. The vice president for finance has a master budget
that summarizes the department budgets,,
It's not practical to put all the department worksheets and the master budget in one large workbook if a few dozen people need to use
the workbook at the same time.

If the managers link the workbooks together, they won't have to fight with each other or with the vice president over whose turn it is
to work with the budget. (Experience indicates that the vice president almost always wins.)

The vice president's workbook will include links to cells in the departmental budget workbooks. As the department managers change
their numbers, the changes can be automatically reflected in the vice president's master budget workbook so the managers and the VP
are all working with the most current data. Each link establishes a relationship between two workbooks. The vice president's workbook
is called the dependent workbook, because each value there depends on a value in another workbook, which is called the source
workbook.

There are two ways to create a link: by using an open workbook as a source or by referring to the path to the workbook's location. The
first method is much easier to use. It's the same as creating any other reference in a formula, but you need to switch to the source
workbook before selecting the cell to reference in the formula.

Before creating the formula that includes a link, open the source workbook. Then, in the dependent workbook, begin entering the
formula with an equal sign (=). At the point in the formula where you want to include a cell reference from the source work book,
choose Window on the menu bar and select the source workbook. Click on the cell that you want to reference, and it will be included.
Notice that the cell reference includes the workbook and worksheet names as well as the cell address:

Workbook name Sheet name Cell address

Workbook name Sheet Name Cell Address

Page 40 of 126
Advancement in MS Excel

OFILAM
='[Book Schedule.xls]Proposed ‘!$B$3

You may prefer to arrange the source and dependent workbooks so that you can see the "result" cell and the cell to be referenced at
the same time. With both workbooks open, choose Window > Arrange to open the Arrange Windows dialog box. Choose how you want
the open workbooks arranged, and then use each workbook window's sizing tool to further size and arrange the windows.

TIP You can arrange copies of a single workbook so you can work in different parts of the workbook in separate windows. Choose
Window > New Window and then open the Arrange Windows dialog box and arrange the windows using the Windows of Active Work -
book check box.

If the workbook is not open, you must provide all the information that Excel needs to find the source workbook, including the full path.
For example, if you want to refer to cell D4 in the Sales sheet of the Proposed Dept. Budget workbook, which is stored

In the Sales Management folder on the C drive, the reference would be ' C: Sales Management\ [Proposed Dept. Budget.xls]Sales’!D4.
There are many places to make a mistake when typing an entry like this. Try to create links with open source workbooks whenever
possible.

Page 41 of 126
Advancement in MS Excel

OFILAM

Linking with Paste Link


If you simply want to include a cell from another workbook (as opposed to using it in a formula), create a link by copying and paste-
linking. Open both workbooks, then select and copy the cell(s) from the source workbook. Then you can do any of the following:

• Activate the destination workbook, and choose Edit > Paste Special from the menu bar, or right-click and choose Paste Special from
the shortcut menu to open the Paste Special dialog box. Click the Paste Link button to create the link.

• Choose Paste Link from the Paste button's drop-down menu.

• Right-click and choose Paste from the shortcut menu. After Excel pastes the selection, click the Paste Options drop-down list and
choose Link Cells to create the link.

Working with Links

When you open the dependent workbook and the source workbook is not open, Excel will ask if you want to update the links. If both
workbooks are open, changes in the source workbook are automatically updated in the dependent workbook.

If the source workbook can be opened by other users, however, they can be making changes to that workbook while you are working
with the dependent workbook. In this case, the links will not be updated automatically; you have to instruct Excel to update the links.

TIP For information on linking from other Office XP applications, see Chapter 16, "Using Excel 2002 with Other Databases." See
Chapter 18, "Using Excel 2002 With the Web," for information on linking to web data sources.

Checking on Your Links

With the dependent workbook open, choose Edit > Links to open the Edit Links dia log box, shown in Figure. Scroll the Source list to
see the attributes of each link the workbook:

Source The file that the link points to.

Type The source type (for example, a worksheet, Word document, or PowerPoint slide).

Update A for Automatic update, M for Manual update.

Status Unknown or Open for Excel workbooks; not applicable for non-Excel sources.

From the Source list, choose the source workbook that you want to check. Click the Check Status button to verify links.

Page 42 of 126
Advancement in MS Excel

OFILAM

NOTE Two very specific types of links are not listed in the dialog box: links in web queries that contain parameters and links in names
that are not used in any workbook formula.

Updating Links
To update links in open workbooks, select the workbooks you want to update. Click the Update Values button to update the dependent
workbook with information from the latest saved version of the source.

Viewing Link Sources

To open the source for a link, select the source you want to open then click the Open Source button. If the source is already open,
you'll be advised that opening the source may result in the loss of data.

Page 43 of 126
Advancement in MS Excel

OFILAM

Changing the Source for a Link

If you move or rename a data source, click the Change Source button to locate the data source and repair broken links.

Breaking Links

Click the Break Links button to replace the link with the last known value for the linked cells.

Setting the Startup Prompt

By default, users who open a workbook with links are asked whether they want to refresh the links. Click the Startup Prompt button to
open the Startup Prompt dialog box and override the default to force or disallow the automatic refresh.
links to other workbooks.

TIP Use the built-in functionality of hyperlinks instead of command buttons or menu items that fire navigational macros.

Page 44 of 126
Advancement in MS Excel

OFILAM

Using Excel Goal Seek to Vary Results


Goal Seek can be used when you know the result of a formula, but not the input value required by the formula to decide the result,
reverse calculation.  You can change the value of a specified cell until the formula that is dependent on the changed cell returns the
result you want.  Goal Seek is found under the Tools menu, and is perfect for mortgage or loan queries. See Also: Multi-Cell Goal
Seek and Excel Multiple Target Seek

For Goal Seek to work effectively, a base model must to be set up in your Worksheet with the data and formulas already in place and
working.

The cell that contains the formula that you want to settle is called the Set cell. The value you want the formula to change to is called
To value and the part of the formula that you wish to change is called By Changing Cell.

The Set cell MUST always contain a formula or a function, whereas the Changing Cell must contain a value only. Not a formula or
function.

Goal Seek must always be activated when you are clicked on the Set cell as the Set cell will always be the formula that you wish to
settle.

Once clicked on your Set cell, select Tools>Goal Seek to see the Goal Seek dialog box. You will see a marquee around your Set
cell.

As you have already selected your Set cell, you need make no changes in the first box. Click or tab to the To value: box  and type in
a value. Click or tab to the final box By changing cell: and select the collapse dialog button to the right of the box to collapse the
dialog box. Select cell that you wish to change. Collapse back through to your dialog box and click OK (Note your cell reference is now
absolute).

As soon as you select OK you will see that Goal Seek re-calculates your formula. You then have two options, OK or Cancel. If we
select OK the new term will be inserted into our Worksheet. If you select Cancel, the Goal Seek box will disappear, and your
Worksheet will be in its original state.

Page 45 of 126
Advancement in MS Excel

OFILAM
Data Validation

1. On the same worksheet, type the list of valid entries down a single column or across a single row. Do not include blank cells in
the list.

2. Select the cells that you want to restrict.

3. On the Data menu, click Validation, and then click the Settings tab.

4. In the Allow box, click List.

5. In the Source box, enter a reference to your list of valid data.

Page 46 of 126
Advancement in MS Excel

OFILAM

6. If you want to select from a list of the entries when you click a restricted cell, make sure the In-cell dropdown check box is
selected.
7. To specify that the entry is not valid if the restricted cells or the cells that contain your list of valid data are blank, clear the
Ignore blank check box.
8. To display messages to prompt for entries and to explain or prevent incorrect entries, specify the types of messages you want
on the Input Message and Error Alert tabs.

To omit display of messages, clear the Show input message when cell is selected check box on the Input Message tab, and
clear the Show error alert after invalid data is entered check box on the Error Alert tab.

Tips

 If the list of valid entries is short, you can type them in the Source box instead of typing the entries on a worksheet, separated

Page 47 of 126
Advancement in MS Excel

OFILAM
by the Windows list separator character (commas by default). For example, you could type Low, Average, High in the Source box
instead of entering the three words on a worksheet.

 If the list of valid entries might change, name the list range, and then enter the name in the Source box. When the named range
grows or shrinks because of changes you make to the list on the worksheet, the list of valid entries for the cell automatically
reflects the changes.

 If the list of valid entries is in another worksheet or workbook, define a name for the external data on the active worksheet. In
the Source box, you can then refer to the name on the same worksheet. For example, if the list of valid entries is in cells A6:A12
on the first worksheet in a workbook named Budget.xls, you could define the name ValidData on the active worksheet to be
=[Budget.xls]Sheet1!$A$6:$A$12 and then enter =ValidData in the Source box.

Example:

Task: We are making a worksheet relating to employees’ data. The Data will run to 21 rows from row 1 to row 21. The first row
contains titles like Name, Desg, BP etc. The actual information pertaining to employees are stored in rows 2 to 21. In column B, in Cells
2 to 21 Designations of the employees named in Column A (in Cells 2 to 21) are to be entered. The designations are only 4 viz. FM,
CM, UDC, LDC. In column B if you try to enter any other designation, the entry should not be accepted.

How to proceed?

In the same worksheet in cells F1 to F4, type down the Designations viz. FM, CM, UDC and LDC.

Select range B2 to B21 (i.e. the range of cells in which the designations are to be entered).

Page 48 of 126
Advancement in MS Excel

OFILAM
Click Validation on Data Menu.
Click the Settings Tab and choose List.
In the Source box type in $F$1:$F$4.
Clear Checkmark on Ignore Blank.
Choose In-cell drop down.

Now click the Input Message Tab and enter Title and Input Message as shown below in the box.

Click OK.

Page 49 of 126
Advancement in MS Excel

OFILAM

Example 2:

In a new worksheet, select cells B2 to B11.


Click Data  Validation  Settings  Allow: List.
In the Source Box type in FM, CM, UDC, LDC.
Choose In-cell drop down.

Click the Input Message Tab and in the Input Message Box tin “ENTRY RESTRICTED TO FM, CM, UDC, and LDC”.

Click OK.

Try entering AWM in cell B2.

The entry AWM is not


accepted.
Input Message that
you entered is shown

Page 50 of 126
Advancement in MS Excel

OFILAM

Restrict cell entries to numbers, dates, or times within specified limits

1. Select the cells that you want to restrict.

2. On the Data menu, click Validation, and then click the Settings tab.

3. In the Allow box, click the type of data.

4. To specify only numbers, click Whole Number or Decimal.


5. To specify only dates or times, click Date or Time.

6. Click the operator you want in the Data box, and then specify the upper or lower limit for the data, or both limits, depending on
the operator you select. You can enter values, cell references, or formulas for the limits.

7. If you want to allow the cell that you're restricting to be blank, or you set limits that use a cell reference or formula that
depends on cells that are initially blank, make sure Ignore blank is selected.
8. To enforce the restrictions you set for blank cells, treating these cells as if they contain zeros, clear the Ignore blank check
box.

9. To display messages to prompt for entries and to explain or prevent incorrect entries, specify the types of messages you want
on the Input Message and Error Alert tabs.

To omit display of messages, clear the Show input message when cell is selected check box on the Input Message tab, and
clear the Show error alert after invalid data is entered check box on the Error Alert tab.

Page 51 of 126
Advancement in MS Excel

OFILAM
Advanced Filter
Excel Advanced Filter

Other than Excel's very popular Auto Filter, we have at our disposal Excel's Advanced Filter. In a nutshell, Excel's Advanced Filter can
be used to filter by more than 2 criterions, where Auto Filter has a max of 2! It also has a very nifty feature that allows us to create
a list of unique items from a list with repeated data. In addition, we can even use Excel formulas for Excel's Advanced Filter
criteria.

Rules for Advanced Filtering

1) You list or table must have headings at row 1 of the table.

2) Your data must be laid out directly underneath their appropriate headings.

3) When using criteria the cell(s) directly above must have exact copies of the table heading(s). See picture below;

4) When using Excel formula criteria the cell(s) directly above must NOT have exact copies of the table heading(s). They should be
blank, or have a heading that is NOT the same as your table heading(s).

5) If using the "Copy to another location" option you can only copy to the same Worksheet as your original table is located. To copy to
another Worksheet you can start by going to Data>Advanced Filter while on the Worksheet your data should be copied to.

6) To create an OR condition place each criteria in a new cell directly below each other, vertically.

7) To create an AND condition place criteria in a new cell directly next each other running left top right, horizontally. See picture below

Page 52 of 126
Advancement in MS Excel

OFILAM

Page 53 of 126
Advancement in MS Excel

OFILAM
FUNCTIONS
Confirm that the correct cells are selected or use the mouse to select the correct cells before expanding the palette with the Expand
Dialog button. After you have selected all the required arguments, click OK to finish the entry and close the Func tion Arguments dialog
box.

As you enter arguments, the current value for the argument is displayed to the right of the text box. The formula result appears below
the text boxes.

As with any formula, the result of the function is displayed in the active cell. The function itself is displayed in the formula bar when the
cell is active.

These steps summarize how to use Excel functions:

1. Click in the cell where you want the result of the function to appear.

2. Type an = symbol. Choose a function from the Recently Used Functions list. If the function does not appear on the list, choose More
Functions or Click the Insert Function button on the formula bar or Choose More Functions from the AutoSum drop-down menu to
open the Insert Function dialog box.

3. Choose a category from the drop-down list and a function from the Select A Function pane. Click OK to open the Function
Arguments dialog box.

4. In the Function Arguments dialog box, select the text box for the first argument. To enter cell ranges, click the Collapse Dialog
button if necessary, and then select the cells you want to include in the argument. Click the Expand Dialog button to return to the
Function Arguments dialog box. Type constants or open the Function box and select another function. Repeat this step for all required
arguments and any optional arguments you need to use.

5. Click OK to complete the entry and close the Function Arguments dialog box.

TIP Sometimes it's easiest to refer to an entire column or row in an argument if any entry in the column or row should be included in
the formula. If, for example, you want to add every entry in column G, you don't need to specify G1 :G65536. To include all cells in
column G, use the range reference G:G. Likewise, use 1:1 to refer to every cell in row 1.

Page 54 of 126
Advancement in MS Excel

OFILAM

Using Everyday Statistical Functions

Excel includes a fistful of complex statistical functions. Everyday functions that you may not think of as statistical functions are also
included in the list, including ail the functions on the AutoSum button:

COUNT Returns the number of numbers in a range. COUNTA Returns the number of entries, including text entries, in a range.

AVERAGE Sums the numbers in a range and divides the total by the number of numbers.

MEDIAN Another kind of average, returns the middle value in a range of numbers.

MODE Returns the value that occurs most frequently. MAX Returns the largest value in a range.

MIN Returns the smallest value in a range.

COUNT is used to calculate the number of cells that have values, including dates, in the specified range. If you want to count the
number of entries including text entries in a range, use the

COUNTA function rather than COUNT.

TlP Subtract COUNT from COUNTA for the same range to find out how many cells are occupied with text rather than numbers.

AVERAGE returns a value called the arithmetic mean—the total of all the values in a range divided by the number of values in the
range. When we talk about averages— bowling scores, test grades, speed on several typing tests—it's the arithmetic mean we're
referring to. However, there are two other types of averages: MEDIAN and MODE. MEDIAN tells you which value is the middle value in
a range, and MODE tells you which value occurs most frequently.

You can routinely use MEDIAN to test the usefulness of an AVERAGE. In a perfect bell curve, mean (AVERAGE), MEDIAN, and MODE
are the same value. If MEDIAN and AVERAGE values are close to each other, then there either aren't too many incredibly high or
incredibly low values in the range, or they offset each other. If the MEDIAN is much lower than the AVERAGE, there are some very
high values that "pull up" the AVERAGE. A higher than average MEDIAN means that there are quite a few extremely low values.

NOTE The AVERAGE function is SUM/COUNT on a range. The AVERAGEA function is SUM/COUNTA for a range, so each text value
adds 1 to the divisor, but does not increase the SUM used as the dividend.

In Figure 5.6, we've used the SUM, COUNT, COUNTA, AVERAGE, AVERAGEA, MEDIAN, and MODE functions on the range of cells in
D4:D18 to quickly report information about pledges for a company fundraiser:

SUM The total in cell D20.

COUNTA The number of employees in G7.

Page 55 of 126
Advancement in MS Excel

OFILAM
COUNT The number of pledges in G8.

AVERAGE The average pledge in G9. AVERAGEA The per employee pledge in G10.

MEDIAN and MODE For the results in Gl 1 and G12

Non pledges are recorded as None in the worksheet, so the AVERAGE function returns the average of those who pledged to the
fundraising effort. If nonpledges had been recorded as zero, then the AVERAGE would include the nonpledges, dropping the average of
the per employee figure in G10, as there would be no text entries.

NOTE The COUNTBLANK function returns the number of empty cells in a range.

Finding and Fixing Formula Errors

Excel makes numbers look believable—even when results are so incorrect that no one should believe them. You can make two kinds of
errors when creating a worksheet. One is a data entry error: typing the wrong number, misspelling a word or name, or forgetting to
type both parentheses in a pair. Excel will let you know when you miss a parenthesis, but there is no software tool that can check to
be sure you enter all your numbers correctly. You can ensure that a number is in an acceptable range (see "Vali dating Data Entry" in
Chapter 14), but your experience and knowledge of historic values is the best guide.

Resolving Logical Errors


The other kind of error is a logical error: adding rather than subtracting or multiply ing the wrong numbers. Some logical errors violate
Excel's rules about how formulas are constructed and result in an error message in the cell or an interruption from the Office Assistant.
Those errors are the easy ones to catch and correct and are discussed in the following section. But errors that don't violate Excel's
internal logic are the really nasty ones, because nothing jumps out and says, "This is wrong!" If you are familiar with the data, you can
check the logic yourself to make sure the results make sense. If you are not conversant with the data, find someone who is and review
the worksheet with them.
Working with Error Codes

Excel has eight error codes that pop up in cells to let you know that a formula requires your attention. The first is the ###### error,
which may be telling you that the data is too wide for the column or too tall for the row. This is easy to fix (hardly an error, but you
get the idea). The codes, listed in Table 5.2, give you information about what caused the error.

Error Code/ Causes


Error Name
##### 1. Data is too wide for the cell.
2. You subtracted one date from another,
and the result is a negative number.
Double-check your formula.
#DIV/0 The number or cell reference you divided

Page 56 of 126
Advancement in MS Excel

OFILAM
Divide by Zero by is either zero or blank. If you see this
in cells you just filled, you needed an
absolute cell reference in the original
formula.
#N/A 1. You omitted a required argument in a
function.
Not Available 2. The cell that contains the argument is
blank or doesn't have the kind of entry
the function requires.
#NAME 1. You misspelled the name of a range or
function.
2. You referred to a name that doesn't
exist.
3. You used text in a formula or format
without putting it in quotes.
4. You left out the colon in a range (B3:
D7).
#NULL You referred to an intersection that
doesn't exist by using a space between
two ranges in an argument.
#NUM 1. You used text or a blank cell in an
argument that requires a number.
2. You entered a formula that creates a
number too large or too small for Excel to
handle.

#REF You deleted some cells that this formula


Invalid requires, so the formula can't find the cell
Reference that it refers to. You may have deleted
some cells by pasting other cells over
them.
#VALUE You entered text when a formula requires
a number or a Boolean value (TRUE or
FALSE).

Excel 2002 includes new tools to help you diagnose and fix errors. Let's return for a moment to the divide-by-zero error created by
copying a relative formula (refer back to Figure 5.5).

Each of the four cells with errors has a green error indicator in the upper left corner. Click any cell with an error indicator and an Error
Options button appears. Select the button and open the button's menu to see the type of error, help on the error, and tools for further
diagnosis:

Page 57 of 126
Advancement in MS Excel

OFILAM

Choose Help on This Error to open the Excel Help page covering divide-by-zero errors. Choose Show Calculation Steps to open the
Evaluate Formula dialog box, shown in Figure 5.7. The dialog box displays the next calculation to be performed: in Figure 5.7, dividing
42 by 0. Click the Evaluate button, and Excel will perform the calculation and show the result: #DIV/0!

NOTE Choose Error Checking Options to view or change the settings for error checking. For details on these options, see "Setting Error
Checking Options* in the next section.

For errors that aren't as obvious, choose Show Formula Auditing Toolbar to access even more tools to help you fix your formula.

Using the Formula Auditing Toolbar

The Formula Auditing toolbar, shown in Figure 5.8, is a toolkit for formula repair. The toolbar has been greatly improved for Excel 2002
and includes features that were formerly available only in the Visual Basic Editor.

Tl P The contents of the Watch Window are saved when the workbook is saved, so the next time you open the workbook, you can
immediately check the cells you're monitoring in the window.
Resolving Circular References

Circular references are a special type of error. Circular references aren't passively flagged in the background—a circular error brings
Excel to a screeching halt. A circular reference occurs when a formula refers to the cell that it is in. For example, when the formula
=SUM(315:320) is entered in cellJ20, Excel tries to addJ20 to itself over and over again. Excel will iterate 100 times; then it will give up
and show an error message letting you know you have a circular cell reference:

Click OK, and Help opens with information about circular references. (Help only opens the first time you create a circular reference in a
session.) Excel displays a blue dot next to the formula that created the circular reference and displays Ci rcular: and the reference for
the offending cell in the status bar. If Help opened, clicking the cell with the circular reference opens the Circular Reference toolbar (or
you can turn it on by choosing View > Toolbars or right-clicking any toolbar).

If there's a circular cell reference anywhere in an open workbook, CIRCULAR appears on the status bar. Use the drop-down list in the
Circular Reference toolbar to find the reference.

Page 58 of 126
Advancement in MS Excel

OFILAM

The drop-down list in the toolbar displays the current circular reference; clicking the drop-down list shows all the circular references in
all open workbooks. The other three buttons on the toolbar are used to trace dependents and precedents and remove all trace arrows.

NOTE See Tracing Errors Visually" in the previous section for help with error tracing.

The precedent arrow shows that all the cells in the row, including the last cell, are included in the formula in the last cell. With circular
errors, the problem is always a precedent—either the current cell address is included in the formula or; more indi rectly, the current cell
is used in a formula in one of the cells included in the current cell formula.

In the example we've used so far, the circular reference was easy to find, because the formula referred directly to the cell it was stored
in. Indirect circular references are harder to find. Just continue clicking the Trace Precedents button, and you'll eventu ally find a
formula that refers to the cell where the circular reference was reported.

TlP If the cell with the circular reference is used explicitly in the offending formula, you can search for it using Find. Open the Find
dialog box (Edit > Find or Ctrl+F) and enter the cell address you're looking for: for example, J20. Find won't help if J20 is included in
the middle of a range in the formula argument, or if J20 is a named cell.

Automatic and Manual Calculation

When you open a workbook, Excel automatically calculates the values for all workbook cells. When you change an entry in a
worksheet, Excel automatically recalculates that cell and all of its dependents. You can continue to vrork while the worksheet
recalculates in the background, but if your worksheet is very large with many formulas, recalculation takes a lot of Excel's attention, so
it will be slower to respond to you..

You can turn off automatic recalculation in the Options dialog box. Choose Tools > Options to open the Options dialog box and click
the Calculations tab. The Calculation options are shown in Figure 5.11.

There are three calculation modes:

• Automatic (the default mode)


• Automatic except for data tables (explained in Chapter 19, "Solving Business Problems Using the Analysis Tools")
Manual

Page 59 of 126
Advancement in MS Excel

OFILAM
The calculation options determine when Excel recalculates worksheet values.

WARNING If you choose Manual, you can turn off another automatic option. Recalculate Before Save, by disabling the
check box. The Calculation options affect all open workbooks.

If you choose Manual recalculation, Excel only recalculates when you force a calcu lation by pressing F9 or opening the
Options dialog box and clicking the Calc Now button. When you force a recalculation, Excel recalculates all open
worksheets in all open workbooks. To only recalculate the current worksheet, hold Shift and press F9

If you choose Automatic Except Tables, Excel automatically recalculates worksheets except for ranges occupied by data
tables, which are used for analysis and forecasting. To recalculate data tables, force a recalculation of the current
worksheet or all open worksheets as explained in the previous paragraph.

NOTE For information on data tables, see "Creating Data Tables" in Chapter 19.
MANIPULATING TEXT AND DATES

Page 60 of 126
Advancement in MS Excel

OFILAM
Many Excel users do little or no number crunching with Excel. Instal they use Excel's powerful text and date functions to
massage data from other sources or for use in other applications, such as Access, SQL Server, or HTML pages. Excel
readily converts a wide variety of file formats, so it's the tool of choice for fixing imperfect data that you receive froi
customers or vendors. With Excel's text and date functions, you can shake and t| almost any type of PC data, turning
barely useable data sets into standardized data bases for use in Excel or publication on the Web.

Working with Text in Excel

A chunk of text data is called a string or sometimes, redundantly, a text string. A stq can be as short as a single
character. Strings can include spaces, symbols, or numba as well as uppercase and lowercase letters. Numbers formatted
using the Text or Sp( cial formats in the Format Cells dialog box are text entries, as are cell contents preceded with an
apostrophe.

NOTE Excel includes more specialized functions for use with numbers and dates fo matted as text. See "Converting Text
to Dates" later in this chapter.

Removing Spaces and Nonprinting Characters

Spaces at the end of a text string entry are called 'trailing spaces, and those at the beginning are leading spaces. Trailing
spaces can be accidentally added when a user hits the spacebar before moving to another column or field in any
application. For large number of extra spaces, however, nothing can compete with space-packed da exported from a
mainframe database. Some mainframe programs export fixed-len^ fields of data and fill unused field lengths with blank
spaces. For example, if the City! in a database is 15 characters wide, a 10-character city name will be followed byfiv
spaces. If the exported data needs to be used to create mailing labels, the spaces mi be removed or a large gap will
appear between the city name and the state name.

Extra spaces in data are inconvenient and difficult to remove manually. You can see them, and even if you could,
manually deleting spaces is tedious work. If you u a find-and-replace operation, you risk deleting spaces within a string
that shouldn' be removed. For example, if you replace all the spaces in the City column, you'll remove the space within a
city (for example, the space between £05 and Angeles) as well as the extra spaces (following Angeles). Removing leading
and trailing spaces while retaining the spaces within a string is a task for the TRIM function.

Page 61 of 126
Advancement in MS Excel

OFILAM
The TRIM function strips only the leading or trailing spaces from a text string; the syntax is =TRIM(str7'ng). If, for example, cell C2 contains the text string Los Angel es followed by four spaces, the formula =TRIM(C2) will return Los Angeles without the spaces.

Function arguments can be constants or references to cells or, as with the SUM function, ranges of cells. For example, the string argument in the TRIM function can be a string typed in as part of the formula =TRIM(" Los Angel es ") or a reference to a cell that contains a string. =TRIM(C2).

Nonprinting characters can't be printed or accurately represented in Excel, which displays them as empty rectangles. Nonprinting characters include printer and data instructions and are sometimes found at the beginning of imported data files. The CLEAN function with the simple syntax =CLEANCstring) removes nonprintable char acters from a string: for example, =CLEAN(C2).

MASTERING THE OPPORTUNITIES

Copying the Results of Text Functions


If you create a formula with TRIM or CLEAN and then delete the celt that contains the original data (C2 in our examples), the formula will return an error. To preserve the results of the formula so you can delete the original data, you'll need to use a variation on copy -and paste.

Begin by selecting and copying the cells with the text formulas. Click in an empty area of the worksheet where you want to paste the results of the formula, and then choose Edit > Paste Special or right-click and choose Paste Special to open the Paste Special dialog boxshown here:

Page 62 of 126
Advancement in MS Excel

OFILAM

MASTERING THE OPPORTUNITIES CONTINUED

Choose the Values option in the Paste section and click OK to paste the results of the formula beginning in the active cell. Now you can delete the cells that contain the original, untrimmed data. If you prefer, you can paste the values over top of the original untrimmed data.

Parsing Data with LEFT, RIGHT, and MID


The LEFT and RIGHT functions return a specified number of characters from the beginning or end of a string. If, for example, you receive a mailing list with the city and two-character state abbreviation in one cell (see the sample in Figure 6.1), you can use RIGHT to list just the two-character abbreviation

Page 63 of 126
Advancement in MS Excel

OFILAM

Page 64 of 126
A
O
T
-

M
A
O

T
Advancement in MS Excel

OFILAM
MASTERING TROUBLESHOOTING CONTINUED

When you click OK, the Function Arguments dialog box opens; in the formula bar,
the function name RIGHT and the corresponding function punctuation are bold. In
the Function Arguments dialog box, the text box for the first argument, Text, has
focus:

Open the drop-down list of functions (on the formula bar) and choose TRIM, or
select More Functions to open the Insert Function dialog box and choose TRIM from
the list of Text functions. When you close the Insert Function dialog box, the
Function Arguments dialog box changes to display the arguments for the TRIM
function, and the function TRIM is bold in the formula bar:

Click in cell C5 in the worksheet to enter the argument for the TRIM function. Use
the formula bar to switch the function displayed in the Function Arguments dialog
box. To display the arguments for the RIGHT function in the Function Arguments
dialog box, click the RIGHT function name in the formula bar. Don't choose RIGHT
from the drop-down list; this appends another RIGHT function. To display the
argument for the TRIM function, click TRIM in the Function Arguments dialog box.

Excel supports up to nine levels of nesting in a formula.

Page 67 of 126
Advancement in MS Excel

OFILAM

To return the area code (the first three characters) from a 10-digit phone number
without parentheses, use =LEFT(ce11_address, 3). If the phone number includes
parentheses around the area code like the numbers in column E of Figure 6.1, you
have two choices. Use LEFT to retrieve five characters; the result will include the
parentheses. To return the area code without parentheses, use the MID function.
The syntax for the MID function is =MID(stn'ng, starting with,number of
characters). =MID(E5,2,3) will return the second, third, and fourth characters in the
telephone number in cell E5.
Using Functions to Change Case
If you're a Word user, you may miss the familiar Change Case command that
appears on Word's Format menu. Excel's equivalents are the UPPER, LOWER, and
PROPER functions, which convert a string to uppercase, lowercase, or proper case.
Use UPPER to make a data set that contains uppercase and mixed case entries
consistent. The UPPER, LOWER, and PROPER functions use only one argument: the
string you want to convert (in quotes) or the address for the cell that contains a
string. If cell C2 contains the text Los angeles, CA:

-UPPERCC2) returns LOS ANGELES, CA


-LOWER(C2) returns "I os angeles, ca
-PROPER(C2) returns Los Angeles, Ca

With the PROPER function, Excel converts the first letter and any letter that follows
a symbol other than a letter (a space, a number, a hyphen) to uppercase. All other
letters are lowercased, so the strings a and an are converted to A and An—not what
you'd want in a title, but "proper" nonetheless. You can combine proper with RIGHT,
LEFT, TRIM, MID, SEARCH (described in the next section), and other text-handling
functions to apply the function to a portion of a text string.

Finding the Position of Text in a Cell

There are two functions used to locate a substring within a string: SEARCH and
FIND. Both have the same basic form: =SEARCH(substr7'ng, string to search,
position to start) and =FIND(substr7'ng, string to search, position to start). In both
functions, the position t'o start argument is optional and is used to begin to start
searching partway into the string. FIND is the original text-searching function used
in early versions of Excel; SEARCH is a beefed-up version of FIND that supports the

Page 68 of 126
Advancement in MS Excel

OFILAM
* and ? wildcards, described in this section.

NOTE Because FIND can't use wildcards, you can use FIND to search for a string
that contains a ? or * symbol. If the substring argument contains a question mark or
asterisk symbol, but the string to search for does not, FIND returns an error.

Using SEARCH
The SEARCH function locates one string within another, so it can be used to find a
single character in a string. The syntax for the function is =SEARCH(stn'ng to find,
string to search in,starting with character); the result is the position of the string
you want to find within the string you want to search. The final argument, starting
with character, is optional. If you don't specify where Excel should start searching, it
begins at the start of the string. For example, to find the comma character in the
combined City/State string in cell C5 (see Figure 6.1), use =SEARCH("," ,C5). Excel
will return the value 8, because the comma is the eighth character in the string
Livonia, MI.

Tl P The SEARCH function is not case sensitive.

SEARCH and LEFT can be combined to return only the city from the string in Fig ure
6.1 that includes the city name, a comma, and the state abbreviation. This is done
by substituting the previously discussed SEARCH formula for the second argument in
the LEFT function, which specifies how many characters to return:

=LEFT(C5,SEARCH(",",C5)).

TIP To determine the length of a text entry, use the LEN function. LEN returns the
length of a string and has only one argument: the string or its cell address. An
example would be =LEN(B15).

SEARCH supports wildcards, so you can use ? to search for a single character or *
to search for more than one character. For example, =SEARCH(" UP? ",35) returns
the starting position of the first three-character string beginning with UP that
appears in J5.

If you need to search for a question mark or asterisk in a string, precede the ? or *
with a tilde (~) symbol. =SEARCH(" ~?", 3 5) returns the position of the question

Page 69 of 126
Advancement in MS Excel

OFILAM
mark symbol in the string in cell J5.

Converting Text to Columns

Excel has another spiffy tool for massaging data: the Convert Text to Columns
Wizard. The wizard is used to separate a column of data that has a delimiter—for
example, a comma between the city and state or between last and first names, or a
hyphen between a catalog number and an item number—or is fixed-length data.

Before invoking the text to columns command, save your worksheet. Insert a blank
column (if needed) to hold the data you'll be splitting off. Select the column you
want to split, and then choose Data > Text to Columns from the menu to open the
Convert Text ; to Columns Wizard. In the first step of the wizard, choose Delimited
to split a column of data separated by a delimiter and click Next. In the second step
of the wizard, shown here, choose the delimiter used in the data, or select Other
and type the delimiter in the text box:

Page 70 of 126
Advancement in MS Excel

OFILAM

The wizard will separate your data into columns based on the delimiter you select If,
for example, you select a comma as a delimiter. Excel will place the data AAA, ,CCC
into three columns, and remove the commas. The text AAA will appear in the first
column, the second column will be blank, and CCC will be placed in the third
column. If you enable the Treat Consecutive Delimiters as One check box, the two
commas will be treated as one, and CCC will be placed in the second column.

Page 71 of 126
Advancement in MS Excel

OFILAM

When you've set your delimiters and the check box, click the Next button. In the
third step of the wizard, select a format for each column of data and a destination
for the columns of separated data:

If you don't specify a destination, the first column of data is placed in the original
column, and the remaining columns are placed to the right of the original column. If
the columns to the right of the original column aren't empty, you'll be prompted to
overwrite them. Click OK to convert the text into separate columns of data.

If the form of the data you want to convert is very consistent, you can use the Treat
Consecutive Delimiters as One option to strip out spaces that follow delimiters. In
column A of our sample worksheet (see Figure 6.1), which has last names followed
by first names, we can set both the comma and the space as delimiters and enable

Page 72 of 126
Advancement in MS Excel

OFILAM
the Consecutive Delimiters check box. When Excel converts column A to text, both
the comma and the space between the last and first names will be removed and the
data will be placed in two columns. With the Treat Consecutive Delimiters as One
option turned off, each first name in column B is preceded by a space (which can
removed with the TRIM function, but that requires an extra step or two). We can't
do the same trick with the City/State data, however. Some city names include
spaces (Los Angeles, St. Paul); if we treat spaces as delimiters, the data will be
incorrectly separated into three, rather than two, columns.

Putting Text Strings Together

Using the CONCATENATE function in Excel 2002, you can reassemble text strings as
easily as you can tear them apart. Concatenation is addition for text; each string is
appended to the end of the prior string. The arguments for the function are each of
the strings you want to add together, separated by commas:
=CONCATENATE(str7ngJL ,string2,str7'ng3...).The strings can be cells or text
entered in parentheses. To concatenate a first name in cell A10 with a last name in
B10, use this formula: =CONCATE-NATE(A10," ", B10). The second argument, " ",
puts a space between the two names.

If you're just concatenating a couple of fields, it's easier to use the symbol for con -
catenation: the ampersand (&). Place the ampersand in your formula between
strings. This formula has the same result as the CONCATENATE formula in the
previous paragraph: =A10&" "&B10.

Use concatenation to combine a text string with the contents of a cell to label the
results of a formula: for example, in Figure 6.2, we've used the formula
CONCATENATE ("Total Vehicle Expense: " ,SUM(B5:B8)) to label the result of the
SUM formula.

Formatting Numbers in Strings

The result of the formula in cell B10 can't be used in other formulas: it's text, not a
number. That also means it can't be formatted using the number formatting tools
like the Currency button on the Formatting toolbar. To format numbers within text,
use the TEXT function, which has two arguments: the text you want to format and
the numeric format to apply to the text, both enclosed in quotes. For example, the

Page 73 of 126
Advancement in MS Excel

OFILAM
formula =CONCATENATE("Total Expenses: " ,TEXT(SUM(B5:B8), "$#0.00") applies
the custom format $#0.00 to the total of cells B5:B8.

Total Vehicle ExEense;J>1E99JuOJ

TIP You can use the Office Clipboard to swipe the formatting from another cell to
use in the TEXT function. Before creating the formula that uses TEXT, select a cell
with the format you wish to use. Open the Format Cells dialog box. On the Number
page, select and copy (Ctrl+C) the contents of the Type text box. When you're
creating the TEXT formula, paste (Ctrl+V) the format in the appropriate spot in the
formula bar or Insert Function argument text box.
Converting Text to Dates

When you import dates from other applications, they are often imported as text
strings. You can easily tell that a date is text rather than a value by widening the
column that the date appears in. Dates are numbers, therefore dates are right-
aligned by default. Text entries are left-aligned.
The DATEVALUE function converts a text string date to a serial value; the syntax of
the function is =DATEVALUE(text string date). If the text string doesn't include a
year (for example, June 8), Excel uses the current year, which is retrieved from the
system clock.

NOTE DATEVALUE converts the date to a serial value (see "Working with Dates
and Times" in the next section), so it can only be used for dates from 1/1/1900 to
12/31/9999. If the date is outside that range, the function returns a #VALUE error.

Creating Day of the Year (Julian) Dates

Another type of date, sometimes erroneously referred to as a "Julian date," is a day-


of-the-year date—a text string created by concatenating the current year with the
number of days since the beginning of the year. For example, January 1, 2001 is
represented as 2001001, where 2001 is the year and 001 is the first day of the year.
The day of the year date was originally used in large computer systems, and served
two purposes: ersatz dates that could be stored in a minimal amount of disk space,
and added and subtracted more easily than text dates.

To create a day-of-the-year date, use the following formula, which assumes that the

Page 74 of 126
Advancement in MS Excel

OFILAM
date being converted to a day-of-the-year date is in cell C2:
=TEXT(C2,"yyyy")&TEXT((C2-DATEVALUE("l/l/"&TEXT(C2,"yy"))+!),"000")

NOTE A modem Julian date (MJD) is the number of days and fractions thereof since
noon on January 1,4713 BCE. Julian dates are used in astronomy and, despite their
name, have no relationship to the Julian calendar, which was used in western
Europe until the 16th century when it began being displaced by the Gregorian
calendar currently used. The Julian calendar was devised, in part, by Julius Caesar;
Julian dates were devised in 1582 by astronomer Joseph. J. Scaliger, who named
them to honor his father, Julius Caesar Scaliger.

Working with Dates and Times

When you enter dates, Excel generally recognizes them as dates. If, for example,
you enter 1/31/2001, 1-31-2001, or October 31, 2001, Excel recognizes it as a date.
When you enter a date, time, or date and time in a form that Excel 2002 recognizes
as a date,

Excel immediately does two things:

• Converts the entry to a serial value.

• Applies the Date/Time format that most closely reflects the form used to enter \
the cell contents. (If you've previously formatted the cell, the format you specified is
applied.)

A serial value is the number of days since an imaginary date, January 0, 1900. Janu-
ary 1,1900 is converted to serial value 1, January 2, 1900 is converted to 2. If you
|haven't changed Excel's default calculation settings, the serial value of 1/1/2001 is
36,892. Times are converted to fractions of a day, so 6 A.M. on January 2, 1900
would be converted to the serial value 2.25, one quarter of the way through the
second serial day. To see the serial value for a date or time, format the cell with a
non-Date/Time
format like General.

NOTE Serial values are often incorrectly assumed to be Julian dates.

Page 75 of 126
Advancement in MS Excel

OFILAM
Dates imported from another application may not fare as well; imported dates are
often stored as text entries. Use the date and time conversion functions to convert
text dates to number dates.

The fact that dates and times are numbers rather than text means you can add,
subtract, and compare cells that contain dates or times. If you subtract 1/1/2001
from 1/2/2001, Excel performs a little sleight of hand and subtracts serial value
36,892 from serial value 36,893 to determine that there is one day between the two
dates. The following are examples of date and time calculations you can complete in
Excel:

• Subtract today's date from a book's due date to see if it is overdue


• Add days to a project's beginning date to calculate the date when the project
should be completed
• Determine how many days fall between two dates
• Sort dates in chronological order
• Subtract the start time for a task from the ending time to determine how long it
took to complete the task

Before you can do these things, you need to make sure Excel recognizes the string
you entered as a date so it can perform the serial value conversion.

NOTE Date and Time formats are applied on the Number page of the Format Cells
dialog box (Format > Cells).

Date/Time Forms That Excel Recognizes

Excel recognizes common date forms, including the date and time entries shown in
column A in Figure 6.3. The dates and times in column C are not recognized as
dates by Excel 2002.

When you enter a date using the two-digit year format (see cell C9 in Figure 6.3),
the cell is flagged with an error indicator. Select the cell and open the Error Options
button's menu to convert the entry to a 1900 or 2000 date.

Page 76 of 126
Advancement in MS Excel

OFILAM
Entering Times
Use the colon symbol to separate the hours, minutes, and seconds in a time entry.
For times from midnight to noon, enter 0:00 through 12:00. For times after noon,
either enter PM (1:00 PM, including a space between the time and PM) or use the
24-hour clock (13:00) or Excel assumes that they're A.M. times.

Not all times are clock times. Enter 3:00:30 for either 30 seconds after 3 A.M. or the
duration three hours and 30 seconds. For both clock and non-clock time entries, you
must enter hours, even if the -number of hours is zero. For example, to enter 20
minutes, enter 0:20, not 20 or :20. Excel treats 20 as 20 hours, and :20 as text.

Excel includes time/date conversion and mathematical functions. The conversion


functions convert or extract date and time data. The mathematical functions are
used for addition and subtraction.

Basic Math with Dates

Dates are stored as serial values, so you can easily add and subtract dates. For
example, to add three days to the date in cell B10, use the formula =B10+3. To
subtract five days, use the formula =810-5. The result in both cases is a serial
value, displayed with the date format of the formula cell or the date format used in
B10 if there was no date format applied to the formula cell. You can format the
results using any of the Date and Time formats.

Excel stores times as decimal values rather than hours, minutes, and seconds. Table
6.1 lists the decimal values for an hour, commonly used fractions of an hour,
minutes, and seconds.

Decimal Values for Units of Time


Time Decimal Value
1 Hour 0.0416666667
45 Minutes 0.0312500000
30 Minutes 0.0208333333
15 Minutes 0.0104166667
10 Minutes 0.0069444444

Page 77 of 126
Advancement in MS Excel

OFILAM
5 Minutes 0.0034722222
1 Minute 0.0006944444
1 Second 0.0000115741

When you're creating formulas, you don't need to enter the decimal values. For
example, to add one hour to a time in cell B10, instead of adding 0.0416666667,
you can enter 1:00 or 1/24 (one twenty-fourth of a day). If you enter 1:00 or 1/24,
Excel converts it to a decimal value. Table 6.2 shows the decimal equivalents for the
hours of the day from midnight
to 11 P.M.

Time Decimal Value


12:00 A.M. 0.0000000000
1.00 A.M. 0.0416666667
2:00 A.M. 0.0833333333
3:00 A.M. 0.1250000000
4:00 A.M. 0.1666666667
5:00 A.M. 0.2083333333
6:00 A.M. 0.2500000000
7:00 A.M. 0.2916666667
8:00 A.M. 0.3333333333
9:00 A.M. 0.3750000000
10:00 A.M. 0.4166666667
11:00 A.M. 0.4583333333
12:00 P.M. 0.5000000000
1:00 P.M. 0.5416666667
2:00 P.M. 0.5833333333
3:00 P.M. 0.6250000000
4:00 P.M. 0.6666666667
5:00 P.M. 0.7083333333
6:00 P.M. 0.7500000000
7:00 P.M. 0.7916666667
8:00 P.M. 0.83333333333

Page 78 of 126
Advancement in MS Excel

OFILAM
9:00 P.M. 0.8750000000
10:00 P.M. 0.9166666667
11:00 P.M. 0.9583333333

Page 79 of 126
Advance
ment in
MS Excel

OFILAM
If your
worksheet
contains
hours
expressed
as
decimals
(for
example,
9.5 for 9
hours and
30
minutes),
divide the
number by
24 to
convert it
to the
decimal
value
shown in
Table 6.2.
Apply a
time
format to
display the
result as

P
age
80 of
126
Advance
ment in
MS Excel

OFILAM
9:30.
Divide
minutes
by 1,440
to convert
minutes to
time
values.

Subtracti
ng Dates
and
Times

Subtract
one date
or time
from
another as
you would
subtract
any
numbers.
Figure 6.4
shows a
portion of
a

P
age
81 of
126
Advance
ment in
MS Excel

OFILAM
worksheet
with
starting
times,
ending
times, and
total
hours,
calculated
by
subtractin
g the
starting
time from
the ending
time. The
formula
returns
the hours
formatted
as a time
(9:00 AM
rather
than
simply
9:00). The
format

P
age
82 of
126
Advance
ment in
MS Excel

OFILAM
shown in
Figure 6.4
is a
custom
format. In
the
Format
Cells
dialog box,
delete the
AM/PM
portion of
the default
time
format to
leave the
custom
format h:
mm.

There is
one small
problem in
our
worksheet.
In cell D5,
the result

P
age
83 of
126
Advance
ment in
MS Excel

OFILAM
is a
negative
number
because
the shift
extended
past
midnight
into a new
day. For
math with
times on
either side
of the
witching
hour, you
need a
more
explicit
formula
that
adjusts if
the ending
time is
prior to
the
starting

P
age
84 of
126
Advance
ment in
MS Excel

OFILAM
time. The
formula
that will
produce
the correct
results in
cell D5
and every
other cell
in column
D is
=(C5+
(C5<B5)-
B5).

The
formula
uses the
conditional
expression
(C5<B5),
which will
return one
of two
results:
TRUE or
FALSE. If

P
age
85 of
126
Advance
ment in
MS Excel

OFILAM
C5 is NOT
less than
B5, the
expression
is false
and Excel
subtracts
B5 from
C5. If C5
IS less
than B5,
the
expression
is true and
Excel
subtracts
a negative
B5 from
C5 (in
effect,
adding B5
to C5).

NOTE For
more
informatio
n about

P
age
86 of
126
Advance
ment in
MS Excel

OFILAM
conditional
s, see
Chapter 7,
"Using
Logical
Functions.
"

Using
Date and
Time
Function
s

Table 6.3
lists
commonly
used date
and time
conversion
functions.
Following
the table,
we'll
provide
some
examples

P
age
87 of
126
Advance
ment in
MS Excel

OFILAM
of how the
functions
are used
in
business
settings.

Common
Date and
Time
Conversi
on
Function
s

Function
DATE

TIME

P
age
88 of
126
Advance
ment in
MS Excel

OFILAM
NOW

TODAY

DAY

MONTH

YEAR

HOUR

P
age
89 of
126
Advance
ment in
MS Excel

OFILAM

MINUTE

WEEKDAY

WORKDAY

NETWORKDAYS

P
age
90 of
126
Advance
ment in
MS Excel

OFILAM

NOTE The
Add-lns
dialog box
will list the
Excel add-
ins
available
on your
computer.

Creating
Dates
with the
DATE and
TIME
Function
s

Use the
DATE and
TIME
functions
to
construct
dates and
times

P
age
91 of
126
Advance
ment in
MS Excel

OFILAM
when the
arguments
(year,
month,
day, hour,
minute, or
second)
are
supplied
by a cell
entry or
another
formula.
For
example,
in the Reel
World
Solar
Customer
Sales
Detail
worksheet
in Figure
6.5, a user
enters the
four-digit
year in cell

P
age
92 of
126
Advance
ment in
MS Excel

OFILAM
B4.

The
formula
=DATE(B4
,1,1)
returns
the
beginning
date in
that year;
=DATE(B4
,12,31)
returns
the last
day in the
year. We
use the
beginning
and end
dates as
arguments
in an IF
function to
determine
if the date
in column

P
age
93 of
126
Advance
ment in
MS Excel

OFILAM
B falls
between
the two
dates and
to apply
conditional
formatting
and
totaling
based on
the
determinat
ion.

Excel can
create
dates from
seemingly
invalid
data. If,
for
example,
you ask
Excel to
create a
date
DATE(200

P
age
94 of
126
Advance
ment in
MS Excel

OFILAM
0,13,1),
Excel
won't
choke on
the idea of
a year
with 13
months.
Excel
treats the
"13th
month" in
2000 as
the first
month in
2001, and
returns
1/1/2001.

The TIME
function
uses
hours,
minutes,
and
seconds
like the

P
age
95 of
126
Advance
ment in
MS Excel

OFILAM
DATE
function
uses
years,
months,
and days.
For
example,
the
formula
=TIME(6,1
5,00)
returns
the time
6:15:00.
'

Retrieving
the
Current
Date and
Time

The NOW
and
TODAY
functions

P
age
96 of
126
Advance
ment in
MS Excel

OFILAM
have no
arguments
. Both
consult
the
computer's
system
clock.
TODAY
returns
the
current
date;
NOW
returns
the
current
date and
time.

P
age
97 of
126
Advance
ment in
MS Excel

OFILAM
TIP The
formula to
display the
current
time,
without
the
current
date, is
=NOW()
-TODAY().
Format
the cell
with any
of the
Time
formats.

Working
with
Date and
Time
Parts

Even if
you only
need to

P
age
98 of
126
Advance
ment in
MS Excel

OFILAM
know the
current
year, you
begin by
retrieving
the entire
date with
the NOW
or TODAY
function.
Then, you
can apply
a DAY,
MONTH,
or YEAR
function to
extract the
precise
informatio
n you
need. The
YEAR
function
returns
the year
from a
date,

P
age
99 of
126
Advance
ment in
MS Excel

OFILAM
serial
value, or
text string
date.

TIP To
convert
the year
(or any
other
date) to
text, wrap
it in a
TEXT
function:
=TEXT(YE
AR(date),f
ormat as
string).

When you
sort a list
of birth
dates or
hire dates,
the dates
are sorted

P
age
100
of
126
Advance
ment in
MS Excel

OFILAM
in
chronolog
ical order.
If you
have every
employee'
s birth
date or
hire date
in an Excel
workbook,
you can
use the
MONTH
and DAY
functions
to create a
birthday
list or
anniversar
y list that
you can
sort by
month and
day,
rather
than by

P
age
101
of
126
Advance
ment in
MS Excel

OFILAM
date.
Figure 6.6
shows a
list of birth
dates,
months,
and days
sorted by
month
first, then
date. In
cell E2,
the
formula is
simply
=MONTH(
D2). The
day
formula in
cell F2 is
=DAY(D2)
.

P
age
102
of
126
Advancement in MS Excel

OFILAM

Page 103 of 126


Advancement in MS Excel

OFILAM
Adding Days, Months, and Years to a Date If you need to increment a date by one day,
you simply add one. What if you need to add a month? How many days do you add:
28, 29, 30, or 31? You could write a function to determine how many days to add based
on the month of the date you're incrementing, but Excel makes it simpler because the
MONTH function has a built-in calendar. Use this formula to strip the date in C2 into a
year, month, and day; increment tli£ month by 2, then reassemble the result into a
date:

=DATE(YEAR(C2),MONTH(C2)+2,DAY(C2))

Use a similar formula to increment years or, if you wish, even days.

EXPERT TIP Excel 2002 still supports the legacy function DATEDIF, which returns the
number of complete years, months, or days between two dates. The syntax for the
function is DATEDIF(startdate, enddate, t7'meun71). Use the following codes, enclosed
in quotes, for the timeunit argument: y for year; m for month; d for day. For example,
=DATEDIF (3/15/1999, 5/15/1999, "m") returns 2'. DATEDIF isn't listed in the Paste
Function dialog box, so you have to type the function name, parentheses, and
commas).

Page 104 of 126


Advancement in MS Excel

OFILAM
Adding Hours, Minutes, and Seconds to a Time Use the TIME function to add hours,
minutes or seconds to a time. For example, if cell B20 contains the time 1:00, the
formula =B10+TIME(1,30,0) adds one hour and 30 minutes to the starting time of
1:00 A.M. and returns 2:30:00.

Calculating With Days of the Year

You can use the DATE and YEAR functions to determine how many days have
passed since a specific date, to figure out the number of days that remain in the
year, or to convert a number of days into a date to find out, for example, what date
the 100th day of the year falls on. To determine the day of the year that a date
represents, use this formula, which assumes that the date is in cell C2, and format it
as a number rather than a date:

=C2-DATE(YEAR(C2),1,0)

The formula subtracts the imaginary date January 0 of the year from the date
(DATE(YEAR(C2),1,0), leaving only the number of days. Use a similar formula and
apply a date format to subtract the date from the last day of the year to determine
days remaining:

=DATE(YEAR(C2),12,31)-C2

To find the date that a specific day of the year falls on, modify this formula, which
we're using to find the 100th day of 2002;

=DATE(2002,1,100)

TIP Another function included in the Analysis ToolPak is the little-known and barely
useful function ROMAN. Give ROMAN a four-digit year, and it returns the Roman
numeral: for example, =ROMAN(1957) returns MCMLVII. Alas, there is no
corresponding function to convert a Roman numeral to a series value date, but if
you really want to know how old the movies are that you're renting for five nights
for $1, you can quickly create a table of Roman numerals starting with a year value,
a ROMAN formula, and a little fill magic.

Page 105 of 126


Advancement in MS Excel

OFILAM
TEXT FUNCTIONS

Extracting Words From Text in Excel

Excel has very powerful and useful Text formula/functions that we can use to
extract words from a string of words. Or, put another way, parse out specific words
from text. The example below show how we can use the Text formula/functions to
do this.

Get Last Word From Text String

Text Sting in A2 is;

Formula/Function is;
=MID(SUBSTITUTE(A2," ","^",LEN(A2)-LEN(SUBSTITUTE(A2,"
",""))),FIND("^",SUBSTITUTE(A2," ","^",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))
+1,256)

Formula/Function result is;

Spreadsheets

Get First Word From Text String

Text Sting in A4 is;

Our main business focus is Excel Spreadsheets

Formula/Function is;

=LEFT(A4,FIND(" ",A4)-1)

Formula/Function result is;

Get Nth Word From Text String (4th word in this case)

Page 106 of 126


Advancement in MS Excel

OFILAM

Text Sting in A6 is;

Our main business focus is Excel Spreadsheets

Formula/Function is;
=MID(MID(MID(SUBSTITUTE(A6," ","^",3),1,256),FIND("^",SUBSTITUTE(A6,"
","^",3)),256),2,FIND(" ",MID(MID(SUBSTITUTE(A6,"
","^",3),1,256),FIND("^",SUBSTITUTE(A6," ","^",3)),256))-2)

Formula/Function result is;

This last one can seem a bit over-whelming. It is the 4 occurrences of the number 3
that determines that we parse out the 4th word. In other words, to get the 5th
word all occurrences of the number 3 would need to be changed to number 4. If it
was the 2nd word we wanted, we would change all occurrences of the number 3
to number 1. Please note, the above formula cannot be used to get the first or
last word. For this you can use: Extract nth Word From Text in Excel

Unlike Microsoft Word, Excel does not give us a ready made way to find out the
number of words in a cell, or a range of cells containing text, or words. However,
with the help of the SUBSTITUTE function/formula and the LEN function/formula
we can. If you are not familiar with these functions/formulas I have written an
explanation below.

SUBSTITUTE

Syntax
=substitute(text,old_text,new_text,instance_num)

What it does

Substitutes new_text for old_text in a text string. Use SUBSTITUTE when you want
to replace specific text in a text string; use REPLACE when you want to replace any
text that occurs in a specific location in a text string.

Example
=SUBSTITUTE(A1, "Sales", "Cost") If A1 had the text "Sales Data" the formula

Page 107 of 126


Advancement in MS Excel

OFILAM
result would be "Cost Data".

Page 108 of 126


Advancement in MS Excel

OFILAM
LEN
Syntax
=len(text)

What it does

LEN returns the number of characters in a text string.

Example
=LEN(A1) If A1 had the text "Sales Data" the formula result would be 10 as A1 has
9 text characters and 1 space character.

Count Words in a Cell

The formula below will return the number of words (not characters) in cell A1

=LEN(A1)-LEN(SUBSTITUTE(A1," ",""))+1

Be aware that superfluous spaces are also counted and may give misleading
results. To ensure accuracy we can simply nest the TRIM formula  function/formula
in the first LEN

=LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1

Count Words in a Range of Cells

The formula below will return the number of words (not characters) in cells A1:A5
=LEN(TRIM(A1&A2&A3&A4&A5))-LEN(SUBSTITUTE(A1&A2&A3&A4&A5," ",""))+1

Page 109 of 126


Advancement in MS Excel

OFILAM

VLOOKUP Function
The VLookup Function can be used to look for numeric values in lists and tables
and to use those values in a calculation.  A perfect example of how VLOOKUP can
be used to glean information is to work out how much tax you are required to pay. 
To do this, we must find an appropriate tax rate based on an annual salary and take
into consideration the number of dependents.

Ideally, one should use Dynamic Named Ranges for Lookup tables. However, for
easier reading we have used range addresses here.

Consider the following table:

VLOOKUP generally requires three arguments

(lookup_value,table_array,col_index_num). 

The lookup value is the annual income, the table array is the address or location of
the Tax Table above (A3:F19) and the column index number is the relevant column
applying; No Dependents, 1 Dependent, 2 Dependents etc. 

Let's say that we earn $60,000 per year, and we have no Dependents.  The
VLookup function to work out the tax payable is written as =VLOOKUP(H3,A3:F19,2)
and will return a value of $18,000.  This is because VLookup scans down the first
column looking for the lookup value ($60,000) in the table, then returns the value in

Page 110 of 126


Advancement in MS Excel

OFILAM
column 2 of the table on the same row ($18,000). This is because the exact
amount of $60,000 exists under Annual Income.

When There is no Exact Match

Let's look at another example.  This time, let's say we earn $43,000 per year and we
have 3 Dependents.  The Function is written in the same way
=VLOOKUP(H3,A3:F19,5).  However as $43,000 cannot be found in the first column
of the Tax Table, VLookup will step back to the closest value, so it scans down the
first column looking for the lookup value ($43,000) in the table, it can't find it, so it
steps back to the closest value.  In this case $40,000.  It then returns the value in
column 5 of the table in the same row ($7,600).

Using VLookup to work out Commission Due

You can also easily use this type of VLookup in a formula.  Let's say you wanted to
work out how much money was due to you, when your earnings were worked out
as a percentage of sales:

You would write the formula as =D3*VLOOKUP(D3,$A$2:$B$10,2).  If your sales


are 5000, then the commission due will be $1,125.00.  This is because 5000 is
multiplied by the result of the VLOOKUP. VLOOKUP scans down the first column until
it locates 5000, then returns the value in column 2 on the same row.

If your sales are 750, then the commission due will be $112.50.  This is because 750
is multiplied by the result of the VLOOKUP.  In this case the VLOOKUP cannot find
750 when it scans down the first column of the table.  It steps back to the closest
value, 500 and returns the value in the second column on the same row, 15%.  So

Page 111 of 126


Advancement in MS Excel

OFILAM
in effect our formula is taking the amount of sales, 750 and multiplying it by 15%,
the amount of commission due.

Tip

A great way to display values to make your table easier to read and understand
when you wish to use VLOOKUP would be to format your cells with a custom
format of "100 to 499" in cell A2, "500 to 999" in A3 etc, so your values display
like in the following table. It is important to note that these are only displayed
values and the true underlying value is still the same as shown in A2:A10 in the
table above.

Page 112 of 126


Advancement in MS Excel

OFILAM

COUNTIF Syntax

=countif(range,criteria)

=COUNTIF(A1:A20,">20")

Which would COUNT all numeric cells in the range A1:A20 where values were
greater than 20.

Note the criteria argument is in the form of a number, expression, or text that
defines which cells will be counted. For example, criteria can be expressed as 20,
"20", "=20",  ">20", "North", "N*".

Let's say we need to count all the cells in A1:A20 that are greater than 2, but less
than 5. The COUNTIF example below will achieve this;

=COUNTIF($A$1:$A$20,">2")-COUNTIF($A$1:$A$20,"<5")

Ok, so if we need to count a range of cells where corresponding cells (on the same
row but different column) meet 1, or more conditions we can no longer use the
COUNTIF. The other formulas we can use, in order of their efficiency, are

Page 113 of 126


Advancement in MS Excel

OFILAM
DCOUNT will count only numeric cells where the cells, or corresponding cells meet a
specified criteria.

DCOUNTA will count all cells (Text or numeric) where the cells, or corresponding
cells meet a specified criteria.
For all examples I will use the data as shown below. Where A2:E25 has been
named: DataTable

DCOUNT

Count the numbers in a column of a list, or database, that match criteria you
specify. For example;

=DCOUNT(DataTable,B2,Criteria)

Would Count all cells in B2:B25 that meet the criteria is the named range: Criteria
(shown below)

The top row of the range: Criteria has exact copies of the headings in the range
DataTable . The reference to cell B2 is telling the DCOUNT to count the numbers in
B2:B25 that meet the criteria. We could replace the reference to B2 with the text
"Quantity", or the number 2 as the "Quantity" column is the second column in the
table.

The criteria text "Bourbon" and "Vodka", under the criteria table heading
"Description", tells DCOUNT that either "Bourbon" OR "Vodka" is a match. The same
principle is used for the "Alcohol Content", i.e. "High" OR "Low". This is then seen by
DCOUNT as an OR condition.

Page 114 of 126


Advancement in MS Excel

OFILAM

Note the repeat of the date under "Use By Date". This is needed when using more
than 2 rows as the criteria as a blank cell is seen as a wildcard character. If we
wanted to count only data that lies between 2 dates, we would need have 2 "Use By
Date" headings in our Criteria range and use: >7-Apr-2005 below one of these
headings and <7-Jun-2005 under another. This is then seen by DCOUNT as an AND
condition.

Download advanced examples of DCOUNT§

DCOUNTA

If we changed the above DCOUNT example to:

=DCOUNT(DataTable,A2,Criteria)

We would always get a result of 0 (zero) regardless of the criteria being


met, or not. This is because DCOUNT will only ever count all numeric cells
and there are none in column A under the "Description" field.

To get a count of these cells, we would need to use the DCOUNTA


function which would count all cells, text or numeric, where the criteria is
being met. That is;

=DCOUNTA(DataTable,A2,Criteria)

SUM as an array formula

Normally, the SUM function will add all numeric cells in a specified range.
However, when used as an array formula with criteria used, it will give us
a count instead of a sum. See below example

=SUM((A2:A25="Vodka")*(C2:C25>VALUE("7-Apr-2005"))*(E2:E25="High"))
+SUM((A2:A25="Bourbon")*(C2:C25>VALUE("7-Apr-2005"))*(E2:E25="Low"))
As with the DCOUNTA example, the above array entered (Ctrl+Shift+Enter) SUM
example would count all rows where the  "Use By Date" is greater than 7-
Apr-2005, the "Description" is either "Vodka" OR "Bourbon" and the
"Alcohol Content" is "High" OR "Low".

The reason it gives a count is because each check is returned as TRUE


(has a value of 1) or FALSE (has a value of 0). So, in the above example,
the third row check would actually look like;

=SUM((0)*(0)*(1))+SUM((1)*(1)*(1))

Page 115 of 126


Advancement in MS Excel

OFILAM
As you can see, unless all 3 criteria are met in at least one of the Sum
functions, the result will always be 0 (FALSE). To read about this in detail,
see our April edition of our free Excel Newsletter

COUNT and IF

=COUNT(IF(A2:A25="Bourbon",IF(C2:C25>VALUE("7-Apr-
2005"),IF(E2:E25="Low",B2:B25))))
+COUNT(IF(A2:A25="Vodka",IF(C2:C25>VALUE("7-Apr-
2005"),IF(E2:E25="High",B2:B25))))

The above, does the same as the array SUM example and must be
entered by pushing Ctrl+Shift+Enter. Note we have told the COUNT to
count all cells in B2:B25 where the criteria is met. In other words, count
all "Quantity" cells where the rest of the specified rows of the
"Description", "Use By Date" and "Alcohol Content" meet the specified
criteria

It is important to know that using the array entered COUNT and IF, or the
SUM as an µarray formula§ over a large number of cells will cause a noticeable
slow down in Excel's recalculation time. The DCOUNT & DCOUNTA are  far more
efficient in this regard. However, as stated at the very start, a Pivot Table is
better still when done correctly.

There are many times that it become necessary to COUNT cells based on multiple
criteria. The examples below will show you 3 ways that this can be done. However,
often the most efficient method is to use a Pivot Table If you are not familiar with
Pivot Tables, I cannot stress enough how much easier spreadsheet life becomes
once you are!

If you are not already aware, the Excel COUNTIF formula/function can only check to
see if specified cells meet one condition, e.g.

Grouping Fields

Grouping data in an µExcel Pivot Table§ can at times be very frustrating as when
you try to group, Excel can tell you that it "Cannot Group that Selection", is "Unable
to Group" the particular field you are trying to group, or the result of the grouping is
not what you expect.  Let's address these common problems and tell you the
reasons as to why they occur. 

Cannot Group that Selection

Page 116 of 126


Advancement in MS Excel

OFILAM
The first problem "Cannot Group that Selection" is normally caused by one of two
things.  The first, and most likely cause, is due to the fact that your Pivot Table data
range includes blank cells within the field in which you are trying to group.  For
example, if you had a column for dates for Date of Birth and within that column
somewhere there was only one blank cell, Excel would not allow us to group by
Date of Birth.  This is because Excel does not know what it should do with the one
blank cell in regards to grouping with date cells.  Basically, what this means is your
column must:

Have no blank fields

Your data range for your Pivot Table should not exceed past the last row of data.

Obviously, it will be quite common once you have created a Pivot Table of data that
you would be adding new information to that table on an ongoing basis.  The
temptation is always there to make your data range for your Pivot Table extend well
past the last row of information in your table and thus include many blank cells. 
Obviously you would do this so when you add more information to your table it
would automatically be included in your Pivot Table the moment you refresh it.
Extending the data range of your pivot table well beyond the last row in your table
will not only cause grouping problems, but also force Excel to reserve excess
memory for all of the blank cells you have included.  This, depending on how many
extra rows you include, can end up increasing your file size by 100% or greater. The
solution to this common problem is quite simple and comes in the form of using a
µdynamic named range§.

The other common reason for not being able to group data is that you have both
text and numeric data in the same field.  This one can be a little bit hard to spot at
times, but just remember by default numbers are right aligned and text is left
aligned.  Normally, simply going back to your data table, selecting the column which
contains what you think is numeric data, changing the alignment to General under
Format>Cells>Alignment will force Excel to return the numbers to their original
state, although this will not change their format.  You may have to widen your
column a little, to actually see whether your data is left aligned (text) or right
aligned (numbers). For more details on dates & numbers seen as text see:
µConvert Dates§ || µExcel Calendar for Valid Dates§ || µExcel Date and Times§ ||
µConverting Text Numbers to Real Numbers§

Pivot Table Products

Saving a Workspace

If you wish to compare either multiple workbooks, or the same workbook over and
over again,  and you have set up a custom view to do this, Excel has the facility to

Page 117 of 126


Advancement in MS Excel

OFILAM
save a custom view as what is known as a workspace.  This is extremely useful
when you µarrange workbooks§ via Window>Arrange, or you are µcomparing the
same workbook§, or µcomparing different workbooks§ using the Compare Side by
Side command.

A workspace is just a file that contains display information about your workbooks,
not the actual workbooks themselves.  To do this go to File>Save Workspace, enter
a file name in the File name: box and click OK.   This will save your workspace as an
.xlw, not a standard .xls file.  Each time you open the workspace, all workbooks will
be opened and displayed in your custom view.

Any changes you make to the Workbooks in the *.xlw file will automatically be
saved as you close either the Workspace as a whole, or all Workbooks individually.

We can use the formula below to return the age of any person in years, months and
days. It makes use of the little known DATEDIF Function

=DATEDIF(A1,TODAY(),"Y") & " Years, " & DATEDIF(A1,TODAY(),"YM") & " Months,
" & DATEDIF(A1,TODAY(),"MD") & " Days"

Where A1 houses the person birthday in a µtrue Excel date§ format. Although this
works, it is good µspreadsheet design§ to have only one occurrence of any volatile
Function (TODAY() in this case) and reference it as needed. For example, place in
any cell the formula: =TODAY() and Enter it. Now µName this cell§: Today and then
whenever you need today's date you simply reference today's date by referencing
the named cell "Today". E.g.

=DATEDIF(A1,TODAY,"Y") & " Years, " & DATEDIF(A1,TODAY,"YM") & " Months, " &
DATEDIF(A1,TODAY,"MD") & " Days"

1. The syntax for the DATEDIF function is;

DATEDIF(Start_Date,End_Date,Unit)

Valid Units are any one of the formats below

"M", "D", "Y", "YM" (The months and years of both dates are ignored) ,"YD" (The days and years of both dates
are ignored) and "MD" (The years of both dates are ignored).

Nested IF Function/Formula Nesting Limit Limitation

One limitation of Excel is that we can only nest formulas up to 7 levels. This is
particularly limiting when trying to add nested IF Functions/Formulas that require
greater than 7 conditions. See Also: µNamed Formula§ method here

Page 118 of 126


Advancement in MS Excel

OFILAM

If you hit the 7 level limit, odds are that you are not using the correct method for
your task. For example, one common use of multiple nested IF Functions/Formulas
is when we wish to have a value returned based on the content of another cell. If
this is your problem, then it's very likely the use of the µVlookup formula§ with a
lookup table will solve your problems! See screen shot below;

µ§

If you are evaluating numbers being entered into a cell you could use the CHOOSE
Function/Formula. For example, if a user can enter a number between and 10 into
A1, you may wish to have the text returned based on the number they enter. See
example below

=CHOOSE(A1,"One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten")

If you Enter the above formula into any cell and then enter a number between 1
and 10 into A1, you will see exactly what it doing. The CHOOSE Function/Formula
can take up to 30 arguments.

µVLookup§ is perfect for numerical values contained in a range.  However if you


tried to use VLookup with text in a table, it's use would be limited, For example
surnames such as Smith, Smithson, Smithy, Smithson-Jacobs would create
problems.  If you entered a surname incorrectly, VLookup will step back to the
closest possible match. 

If you wish to glean information from a table that uses text, you can use VLookups
optional fourth argument called match-type.  This argument forces VLookup to
return #N/A if an exact match cannot be found in the first column of your
table. This type of VLookup is perfect to glean information from an address list.

Let's say we wanted to find out the phone number of Smithson-Jacob.  We would
use =VLOOKUP(B15,A2:E11,4,FALSE).  Telling Excel to lookup Smithson-Jacobs in
the table range and return the value on the same row in the fourth column.  By
using the optional fourth argument, FALSE, Excel is forced to return either an exact
match (as it has done) or #N/A if it can't find an exact match. See µLookup
Functions§ here on how to stop the #N/A in lookup formulas.

If we wanted to find the Date of Birth from within the Table we could use
=VLOOKUP(B15,A2:E11,5,FALSE), which tells Excel to return the value in the fifth
column on the same row.

µ§

Page 119 of 126


Advancement in MS Excel

OFILAM
Another way that we could write the same VLookup is by referring to the Surname
within the table range like this =VLOOKUP(A6,A2:E11,5,FALSE)

Mask Excel Time Entries.

Unlike Access, Excel does not allow for us to mask time and/or date entries.
However, we can use the µWorksheet_Change Event§ to achieve masked time
entries. For the code to work times should be entered as 4 digits, e.g. 2244, 0130,
1325 will change to 22:44, 01:30 and 13:25 respectively. Note how the time mask is
only applicable to the range A1:A100, but can be any range. You can change the
display format (.NumberFormat = "[h]:mm") of the code to suit your needs.

To insert the code, right click on the Sheet name tab, select View Code and in here
paste the code below;

Private Sub Worksheet_Change(ByVal Target As Range)


Dim vVal
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("A1:A100")) Is Nothing Then Exit Sub

With Target

vVal = Format(.Value, "0000")


If IsNumeric(vVal) And Len(vVal) = 4 Then
Application.EnableEvents = False
.Value = Left(vVal, 2) & ":" & Right(vVal, 2)
.NumberFormat = "[h]:mm"
End If
End With
Application.EnableEvents = True
End Sub
As you may already know, we can use µVLOOKUP§, or µINDEX/MATCH§ to
locate the first occurrence of a specified value in a list, or table of data.
However, Excel has no ready made formula that allows us to locate say the
second, or third occurrence etc of a specified value. To do this would
normally the use of a Custom Excel VBA Function, or a horribly inefficient
µA§µrray formula§. Below you will find 2 ways to locate the nth occurrence of

Page 120 of 126


Advancement in MS Excel

OFILAM
a specified value and return the value on the same row but in another
column. One is straight forward and requires no VBA, while the second does
make use of Excel VBA. Neither need array formulas!

Find the Nth Occurrence of Specified Value Non VBA Method.

I will use the table of data as shown below for the example, sorted only for easier reading.
Note the formula that resides in the selected cell A2 (see Formula bar) is: =B2&"
"&COUNTIF($B$2:$B2,B2) and is used to obtain a count of each occurrence. It is vital to note
the absolution of $B$2 and the relative row reference of $B2. This is vital so when you copy
the formula down, it will extend the COUNTIF range accordingly.

Page 121 of 126


Advancement in MS Excel

OFILAM

Note also that this extra column can be hidden from view to make for less clutter. If
you have not already guessed, we now simply use a standard VLOOKUP, or
INDEX/MATCH to obtain the occurrence we want, for example;

=VLOOKUP("Bill 3",$A$1:$C$22,3,FALSE)

Would yield a return value of "Bill # 3"

Left Lookup in Excel

Excel is very rich in Lookup formulas, with perhaps the µVLOOKUP§ being the most
popular. However, the draw-back with all Excel's Lookup formulas is that they will
only look in the left most column and return the result from the corresponding cell
to the right. There are times when users need to lookup data in any column of a
table and return the corresponding cell to the left. To do so, we can use the INDEX
& MATCH Formula/Functions

INDEX & MATCH

The INDEX Formula/Function has 2 versions available. We will only be using the first
version here;

1) INDEX Formula/Function. Returns the value of a specified cell or array of cells


within array.

Syntax
INDEX(array,row_num,column_num)

2) INDEX Formula/Function. Returns a reference to specified cells within reference.

Syntax
INDEX(reference,row_num,column_num,area_num)

The MATCH  Formula/Function Returns the relative position of an item in an array that


matches a specified value in a specified order. Use MATCH instead of one of the LOOKUP
functions when you need the position of an item in a range instead of the item itself.

Syntax
MATCH(lookup_value,lookup_array,match_type)

Page 122 of 126


Advancement in MS Excel

OFILAM
Left Lookup

To do a left lookup we can use the INDEX Function/Formula with the MATCH
Function/Formula nested in the Row_num Argument of the INDEX
Function/Formula. Let's say our table of data resides in a table named DataTable
and this named range refers to: $A$1:$D$9 See Image below;

As you can see, the first example uses the formula:

=INDEX(DataTable,MATCH("RKP4",ID,0),1) and makes use of the Named ranges.


The second does exactly the same, but does not use the Named ranges, i.e.
=INDEX($A$1:$D$9,MATCH("RKP4",$C$1:$C$9,0),1)

In Laymen's terms, the formula is telling Excel to use the range $A$1:$D$9 as the array
Argument, row 4 for the row_num Argument (returned via the MATCH Formula/Function) and
Column 1 of the array $A$1:$D$9. Which returns the data in cell A5 (Mary K).

Returning the Column Number and Row Number

We can either take this a step further and ensure the column_num argument supplied is
always correct by nesting another MATCH Formula/Function into the column_num argument.
The formula for this would be;

Page 123 of 126


Advancement in MS Excel

OFILAM
=INDEX(DataTable,MATCH("RKP4",ID,0),MATCH("Name",Headings,0))

Page 124 of 126


Advancement in MS Excel

OFILAM

Page 125 of 126


AB

C
Advancement in MS Excel
1
OFILAM
Amount

 Name

Age

$256.95

Bill

56

$125.63

Joe

22

$25.66

Mary

59

$548.00

Dave

21

Page 126 of 126

You might also like