0% found this document useful (0 votes)
73 views78 pages

CP Lab

Uploaded by

vishalvishu6248
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views78 pages

CP Lab

Uploaded by

vishalvishu6248
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

INDEX

S.no Particulars Page no


Microsoft Excel Unit-I

Introduction to MS-Excel

Formatting cells
Cell referencing
Creating & using formulas Filling a
series
Sorting data Statistical functions
Financial functions Data functions
Graphs and charts
Building simple macros. Querying
External Data in Excel

Microsoft Excel Unit-II Creating


Pivot Tables
Macros - Relative Macros Macros -
Absolute Macros

Microsoft Access Unit-I


Introduction to MS-Access Creating
a database
Creating a table Entering and
editing
Filtering and displaying data data-
sorting
Microsoft Access Unit-II
Building of macros
Transfer of data between Excel &
AccessSQL Queries in Access
Creating & Querying using forms
Creating & printing reports

1
Microsoft Excel - Unit-I
Creating a New Workbook

The lower right corner of the active cell has a small box called a Fill Handle. Your mouse
changes to a cross-hair when you are on the Fill Handle. The Fill Handle helps you copy data
and create series of information. For example, if you type January in the active cell and then
drag the Fill Handle over four cells, Excel automatically inserts February, March, April and
May.

If you are already in Excel and you want to create a new workbook, choose New from the
File menu or click the New tool on the toolbar. If you choose New from the file menu the Task
Pane will open on the right side of the Excel worksheet. To create a blank workbook, click
Blank Workbook inthe Task Pane, and a new workbook opens.

Managing Multiple Workbooks

Excel enables you to have more than one workbook open simultaneously. Each open
workbook appears on the Window menu. The document with the check next to itis the active
document. To switch to another document, simply choose that document from the Window
menu.

To navigate between worksheets within a workbook, click the worksheet tab you want to
activate. Double-click a worksheet tab to change its name.

Entering and Editing Data

Entering Data

You can enter text, numbers and dates in an Excel worksheet. In Excel¹s terminology,
numbers and dates are called values and text is referred to as a label. To enter data of any
type, click on the cell you want to contain that data, and then type the information you want in
the cell. When you begin typing, your data also appears in the formula bar. When you have
finished typing the data for the active cell, press the Returnor Enter key.

Editing Data

The easiest way to edit the contents of a cell is to select the cell and then retype theentry.
The new entry replaces the old contents. For example, to change the number in cell B6 to
199, select cell B6, type 199 and press Return. This method works well with numbers, but is
more difficult when editing long text labels or formulas.

The formula bar gives you more flexibility while editing. When the mouse pointer moves
into the formula bar, it changes shape to an I-beam, signifying that you can enter or edit text.
Text in the active cell appears in the formula bar and you can edit it there.
Use the mouse to select the text you want to change in the formula bar and then type

2
the new text. Excel automatically replaces what is selected. Don't forget to press the Return
key when you finish editing a cell.

You can also edit labels and values directly in cells. Double-click on the cell you want to
edit. This puts an insertion point in the cell. Edit the contents of that cell the same way you
would using the formula bar.

Moving the Active Cell

Cell selection and movement around the worksheet are similar operations in Excel.
To select a given cell or make it active, simply click on that cell. Use the mouse or the arrow
keys to move around the worksheet. For example, if you press the right arrow key twice you
move two cells to the right.

Refer to the table below for additional information on using the keyboard to navigate a
worksheet.

To move Press this


key
One cell left Left Arrow
One cell right Right Arrow
One cell up Up Arrow
One cell down Down Arrow
To top of worksheet (cell A1) Control Home
To last cell containing data Control End
To end of data in a column Control Down
Arrow
To beginning of data in a Control Up Arrow
column
To end of data in a row Control Right
Arrow
To beginning of data in a row Control Left
Arrow

Go To Command

A quick way to move a large distance on a worksheet is with the Go To command on the
Edit menu. When you select the Go To command, a dialog box prompts you to identify the
cell. Enter the cell reference and click OK or press Return.

Clearing Cell Contents

To clear the contents of a cell choose Clear from the Edit menu. Then, select what you
want to clear from the cell: All, Formats, Contents, or Notes. Most frequently you will want to
clear the Contents of a cell. Pressing the Delete key also clears the contents of cells.
3
Undoing Mistakes

If you make a terrible mistake and you accidentally delete important data. Use the
Undo command on the Edit menu or the Undo tool to correct the mistake.

Copying and Moving Data

Copy selected data from one cell to another with the Copy and Paste commands, or with
the Drag and Drop procedure. If you want to move data instead, use the Cut and Paste
commands, or the Drag and Drop procedure.

These commands and procedures are described below.

Cut
The Cut command extracts the selected data and puts it on
the Clipboard, a temporary storage area. The contents of the Clipboard are overwritten
with each copy or cut.
Copy
The Copy command puts a copy of the selected data onthe Clipboard.
Paste
The Paste command inserts the Clipboard¹s contents into the active cell. Selected
data is replaced by pasted text.
Drag and Drop
This procedure does not involve the Clipboard and works best when moving data
a short distance. To move cells, position the mouse on the cell borders. Wait until the
mouse changes to a left-pointing arrow. When the mouse is this shape, press and drag
the data to the new location.

Formatting Data

Changing formats using the toolbar

In Excel, you can change text fonts and styles in the worksheet. Excel has a Formatting
toolbar to simplify basic formatting tasks. The Formatting toolbar appears inthe figure below.

The formatting toolbar has several tools you can use to change formats. The B button
makes cells bold, the I button italicizes cells and the U button underlines. Use these buttons to
turn formats off as well as on. For example, if cells are bold and you want to turn off that
format, select the cells and click the B button. The toolbar also hasbuttons to change font and
size.

4
Font tab in Format Cells

The formatting toolbar offers quick access to varying text formats. For a more complete
selection of formatting options, use the Font tab in the Format Cells dialog box.

In the Font section you can select Font, Size, Style, Color and Effects. Notice the Preview
area in the dialog box. This shows a preview of the font and style you select before you click
the OK button.

Alignment

By default, Excel left-aligns labels and right-aligns values in a worksheet. You can change
cell alignment using the toolbar or the Format Cells command.

The toolbar has text alignment icons next to the bold and italic icons. You can left-align,
right-align, or center text within a cell using these buttons. Select the cell(s) you want to align
and click the appropriate alignment button on the toolbar.

The toolbar also has a button that will center a label over a range of cells, for example
centering a title over a report. To center data over a range of cells, select the cell you want to
center and the columns you want to center it over and click the Center over Cells button
(shown at right).

Format Alignment command

You can also change the alignment of data within cells using the Alignment section of the
Format Cells dialog. This dialog box also has options to change the orientation of text (i.e.
sideways or vertical) and a box to wrap text within a cell.

Changing Numeric Formatting

To change the format of a number, choose the Cells command from the Format menu. In
the Format Cells dialog box, Excel displays different tabs for various formatting types. To
change numeric formats, click the Number tab. Select the category you want and then the
actual format. For example, to display numbers as currency with two decimal places, select
the Currency category, enter 2 for the number of decimal places, and select the appropriate
currency symbol. Or to display a number as a percentage, choose the Percentage category
and select the number of decimals you want to display.

Placing borders around cells


The toolbar has a button for placing borders around cells. You can also use the Border
section of the Format Cells dialog box, which provides more options. Select the cells you want
a border on and choose the desired format from either the toolbar or the Format Cells dialog
box.

5
Shading cells
To apply a specific pattern or color to a range of cells, use the Patterns section of the
Format Cells dialog box. The sample area in the Patterns dialog box displays what the
selected colors and patterns will look like. You can also apply a solid color using the Fill Color
tool on the Formatting toolbar.

Changing column width with the Format menu

To change column width using the Format menu, select the column or columns you wish
to change and choose Column then Width. In the Column Width dialog box, type a number for
the width of the column. The number represents the number of characters that can fit in the
cell. The default column width is 10, which means a column is wide enough for ten, Helvetica
10-point characters. Choose Best Fit to automatically widen a column to accommodate the
widest label, or click the Hide button to hide the column completely. Hiding columns is useful
when you have data that you do not want to print.

* Changing row height is similar to changing column width. Select the row(s) you
wish to change and choose Row then Height from the Format menu.

Changing column widths by dragging column borders

You can change column widths by dragging column borders with the mouse. Move the
mouse pointer to the right hand border of the column you wish to change. The mouse pointer
will change shape to a left and right pointing arrow as seen below.

Click and drag the mouse to adjust the column width. Note that when you are adjusting
the width in this way, a numeric width indicator appears in the upper left part of the formula
bar.

Freezing rows/columns
Freezing panes allows you to select data that remains visible when scrolling in a sheet. For
example, keeping row and column labels visible as you scroll.

To freeze a pane, do one of the following:

The top horizontal pane Select the row below where you want the split toappear.

6
The left vertical pane Select the column to the right of where you want the split to
appear.

Both the upper and left panes Click the cell below and to the right of whereyou want
the split to appear.

1. On the Window menu, click Freeze Panes.

Copy and Cut (Move)

Cut or Copy Cells

▪ When you select a cell or cells to be copied, a marquee border surrounds the cells. After
you paste, the marquee border is still active.

Click the ESC key to remove the marquee border.

▪ When you need to insert copied or cut cells, you do not need to insert cells first. Simply
click on INSERT > COPIED (or CUT) CELLS on the menubar. A dialog box will be
displayed giving you the option to determine how the cells will be inserted.

Copy or Move a Worksheet

▪ Don’t just cut or copy and paste – you may lose some formatting
▪ Use EDIT > MOVE OR COPY SHEET on the menubaror
right click on the sheet tab and select MOVE OR COPY
▪ Select the workbook you are moving or copying the sheet to
▪ Select the position in the new workbook you want to place theworksheet
▪ BE SURE TO CLICK ‘CREATE A COPY’ if you want to copy the worksheet – otherwise,
the worksheet will be moved!

PASTE

In addition to the Paste Options button , the Paste icon on the Standard toolbar has a
drop down arrow next to it to display options that you can select when you use Paste from the
toolbar.

7
Formulas and Functions

Formulas and functions that perform calculations are the true power ofspreadsheets.

Formulas

To build a formula, first select the cell in which you want the results to appear. In Excel, all
formulas start with the = sign. After the = sign, type the cells you want to add orsubtract along
with the mathematical operation you wish to perform. For example, to addthe January sales in
the worksheet below, the formula would be =B3+B4+B5. If you want to subtract February
Widget Sales from January Widget sales, the formula would be
=B3-C3.

Building many formulas can quickly become tedious. Fortunately, the Copy
command described earlier also works with formulas.

Copying Formulas

The easiest way to copy a formula is with the Fill Handle in the lower right corner of the
cell. Create your initial formula and then position the mouse on the Fill Handle. When the
mouse changes shape to a cross-hair, press and drag over the adjacent cells you want to
copy the formula to.

SUM( ) function

The SUM( ) function is probably the most common function in Excel. It adds a range of
numbers. To build a SUM( ) function, begin by typing the = sign; all functions begin with the =
sign. Next type the word SUM followed by an open parenthesis. You must nowtell Excel which
cells to sum. Using the mouse, click and drag over the range of cells youwish to add. A dotted
outline will appear around the cells and the cell range will be displayed in the formula bar.
When you have the correct cells selected, release the mouse button, type a closing
parenthesis and press the <Enter> key.

If you do not want to use the mouse, type in the references of the cells you want to sum.
For example, to add cells B3 through B5, type =SUM(B3:B5). Excel interprets B3:B5 as the
range of cells from B3 to B5.

AutoSum button
In Excel, the standard toolbar has a button that simplifies adding a column or row of
numbers.
The AutoSum button, which resembles the Greek letter Sigma (shown at right), automatically
creates a SUM( ) function. When you click the AutoSum button Excel creates a sum function
for the column of numbers directly above or the row of numbers to the left. Excel pastes the
SUM( ) function and the range to sum into the formula bar. If the range is not correct, simply
select the proper range with your mouse on the worksheet. When you have the correct range
entered, press the <Enter> key to complete the function.

8
Using the Insert Function Button
The Insert Function Button is located by the Formula Bar.
Click the Insert funtion button in to activate the Insert Function dialog window.

First, choose the Function Category you are interested in from the select a category drop
down menu.

Then select the function you want in that category. When you have selected the proper
function click OK.

In the Function Arguements dialog box you specify the cells the function will operate on,
which are called its arguments. Select the cells with the mouse and click OK. Notice the
creation of the function in the formula bar.

What is a CELL ?

In a spreadsheet the CELL is defined as the space where a specified row and column
intersect. Each CELL is assigned a name according to its COLUMN letter and ROW
number.

In the above diagram the CELL labeled B6 is highlighted. When referencing a cell, you should
put the column first and the row second.

What is a COLUMN ?

In a spreadsheet the COLUMN is defined as the vertical space that is going up and down the
window. Letters are used to designate each COLUMN'S location.

In the above diagram the COLUMN labeled C is highlighted.

Inserting A Column

9
Sometimes we (all) make mistakes or things change. If you have a spreadsheet designed and
you forgot to include some important information, you can insert a column into an existing
spreadsheet. What you must do is click on the column label (letter) and choose in Columns
from the Insert menu. This will insert a column immediately left ofthe selected column.

As you can see from this example there was a blank column inserted into the spreadsheet.
You might wonder if this will affect your referenced formulas. Yes, the Referenced cells are
changed to their new locations. For example:
Cell C4 was =C3+B4and now is =D3+B4

Inserting A Row

Likewise, we can also insert rows. With the row label (number) selected you must choose the
Row from the Insert menu. Again this will insert a row before the row youhave selected.

The formulas will be updated to their corresponding locations.


C3 was = C2+B3NOW C4=C2+B4

Cells and Cell References in Excel

Cells and cell references in ExcelCell Facts

● Data is stored in cells in an Excel spreadsheet.


● Each small rectangle in a spreadsheet is a cell.
● A cell is the intersection point of a column and a row.

10
Column and Row Facts

● Columns run vertically in a spreadsheet and are identified by a letter.


● Rows run horizontally and are identified by a number.
● There are 65,536 rows, 256 columns, and over 16 million cells in a worksheet.

Cell References in Formulas

Cell References in Formulas

While the formula in the previous step works, it has one drawback. If you want to change the
data being calculated you need to edit or rewrite the formula.

A better way would be to write formulas so that you can change the data without having to
change the formulas themselves.

To do this, you need to tell Excel which cell the data is located in. A cell's location in the
spreadsheet is referred to as its cell reference.

To find a cell reference, simply look at the column headings to find which column the cell is in,
and across to find which row it is in.

The cell reference is a combination of the column letter and row number -- such as A1, B3, or
Z345. When writing cell references the column letter always comes first.

So, instead of writing this formula in cell C1:

=3+2

write this instead:

= A1+A2

Note: When you click on a cell containing a formula in Microsoft Excel (see the example
above), the formula always appears in the formula bar located above the column letters
(circled in red in the example).

11
Absolute Positioning

Sometimes it is necessary to keep a certain position that is not relative to the new cell
location. This is possible by inserting a $ before the Column letter or a $ before the Row
number (or both). This is called Absolute Positioning.

A B C If we were to fill down with this formula we would have the exact
1 5 3 =$A$1+$B$1 same formula in all of the cells C1, C2, C3, and C4. The dollar
2 8 2 =$A$1+$B$1 signs Lock the cell location to a FIXED position. When it is copied
3 4 6 =$A$1+$B$1 and pasted it remains EXACTLY the same (no relative).
4 3 8 =$A$1+$B$1

Excel
Formulas
:

This first formula will be as simple as they come and will teach you the basic form of an
Excel formula. Create a new spreadsheet and then follow these steps:

1. Select cell A1
2. Type the following basic arithmetic formula into cell A1: =1+1

3. Press Enter and notice how cell A1 changes from your formula to the result!

This may seem simple, but there are a some very important things you should get out of
this example. When you start off a cell entry with the equal sign "=" you are telling Excel that
you want it to evaluate the following formula.

In our case we had a simple "1+1" we wanted Excel to solve for us. You can do this for
addition, subtraction, multiplication, division and any other operation you can think of.

Remember, if you do not start your entry with the equal sign, then Excel will not evaluate
the cell!

Using Cells to Create Dynamic Formulas


12
The most powerful aspect of Excel is not the simple calculator abilities we describesin our
first formula example, but rather the ability to take values from cells to be used in your
formulas.

Let's set up a basic sales spreadsheet to help explain this topic.

1. In cells A1-D4 enter the following information:

Notice: that cell D2 and D3 are blank, but should contain the amount of money from
selling 150 candy items and 3 vegetables. By referencing the Quantity and Price cells
we will be able to do this! Let's begin with Candy.
2. Note:It is very important to follow these steps exactly without interruptions! Select cell
D2, candy's "revenue", and type the equal sign "=" to begin your formula.
3. Left-click on cell B2, Candy's Quantity and notice your formula is now "=B2"

4. We want to multiply Quanity(B2) by Price(B3) so enter an asterisk (*)

5. Now left-click on Candy's Price (C2)to complete your formula!

6. If your formula looks like ours then press Enter, otherwise you can manually enter the
formula "=B2*C2". However, we really think it is easier and preferred to click on cells to
reference them, instead of entering that information manually.
7. After you pressed Enter your Candy Revenue cell should be functioning properly and
contain the value 75.

8. Using your newly gained knowledge please complete Vegetable's Revenue by


repeating steps 2-7 for Vegetable
9. Your spreadsheet should now look like this:

10. Cheatsheet: If you are having trouble creating the formula for Vegetable's Revenue it is
"=B3*C3"

Advanced Excel Formulas: Using Formulas in Formulas

Now that we have created separate revenues for both Candy and Vegetable it would be
nice to somehow combine these two values to get the Total Revenue. Although both
Vegetable Revenue and Candy Revenue contain formulas, we can still use these cells as we
have been doing and add them together to get our total.

13
1. Select cell D5 (directly below "Total")
2. Type the equal sign "="
3. Left-click cell D2
4. Type the plus sign "+"
5. Left-click cell D3. Cell D5 should now contain this formula "=D2+D3":

6. Press Enter to complete your Total Revenue!

Excel Shortcuts: Files

This small group of shortcuts is useful for opening, closing and saving your Excel
workbooks.

● Ctrl+S: Save your Excel workbook


● Ctrl+O: Open an existing Excel workbook
● Ctrl+N: Create a new Excel workbook

Excel Shortcuts: Editing

These are common shortcuts you will use to edit your Excel workbook. Our favorite
shortcut in this list is, quite obviously, Ctrl+Z.

● Ctrl+C: Copy the current selection to the clipboard. After you copy something, you can
paste it with the paste shortcut.
● Ctrl+V: Paste the current item from the clipboard.
● Ctrl+X: Cut the current selection and place it on the clipboard, which can be pasted.
The difference between cut and copy is that cut will delete your selection, while copy
will not.

● Ctrl+Z: Undo your last change. This is can be repeated to remove again and again to
undo many changes.
● Ctrl+Y: Redo your last Undo. This only is available if you have just issued an Undo
command.

● Backspace: Deletes the current cell and enters edit mode for that cell. This will only
delete one cell and not a selection.
● Delete: Deletes the current selection. Use the delete key when you want to delete
more than one cell at a time.

Excel Shortcuts: Getting Around

These shortcuts will help you move around your Excel workbooks and worksheets with
great ease!

14
● Page Up: Move one page up in your worksheet
● Page Down: Move one page down in your worksheet. Note: The number of rows
moved in both page up and page down depend on how many rows are currently
displayed. The more rows you have displayed the greater amount the row jump will be
when you do a page up/down.
● Ctrl+Home: Move to the beginning of your worksheet
● Ctrl+End: Move to the end of your worksheet

● Tab: Move right one column


● Shift+Tab: Move left one column

● Ctrl+Page Up: Go back one worksheet


● Ctrl+Page Down: Go forward one worksheet. Note: If you are not using multiple
worksheets in your workbook you will probably not use this shortcut!

Excel Shortcuts: Formatting

These shortcuts will help you quickly format your data.

● Ctrl+B: Toggles bold on and off for your selection


● Ctrl+I: Toggles italic on and off for your selection
● Ctrl+U: Toggles underline on and off for your selection

● Ctrl+1: Opens up the Format Cell popup

Excel Shortcuts: Menu

These shortcuts allow you to active the various options on the menu bar without have to
mouse-click them. Note: These shortcuts use Alt as their combination key.

● Alt+F: Accesses the File menu


● Alt+E: Accesses the Edit menu
● Alt+V: Accesses the View menu
● Alt+I: Accesses the Insert menu
● Alt+T: Accesses the Tools menu
● Alt+D: Accesses the Data menu
● Alt+W: Accesses the Window menu
● Alt+H: Accesses the Help menu

After you have used one of these shortcuts you can use the arrow keys to navigate the
menu choices and use the Enter key to select a choice.

Excel Shortcuts: Selecting

These shortcuts help you to quickly select items in your Excel file in various ways.

● Shift+Spacebar: Select the current Row

15
● Ctrl+Spacebar: Select the current column
● Ctrl+A: Select All, will select everything on the current worksheet. This is most often
used in conjunction with the copy shortcut.

Excel Shortcuts: Miscellaneous

And the two black sheep of the shortcut essentials:

● F1: Opens up the quick help feature


● Ctrl+P: Print your worksheet

Excel Sort

Sorting in Excel lets you easily reorder your data based on the type of sorting that you
choose. This lesson will show you how to do a normal and reverse alphabetical sort,as well as
descending numerical ordering.

Raw Unordered Data

Imagine that you were teaching an English class and just collected the homework
assignment for that day. The papers are in no special order, but you know that Excel can sort it
all out for you anyways. You plough through the jumble of papers and enter the data into
Excel, ending up with something that looks like...

With the data enetered you are now ready to begin sorting in Excel.

Excel Sorting: Alphabetical Order (Ascending)

The most common type of sorting, and one that is applicable to our situation, is
alphabetical ordering. This kind of ordering places the cells that start with the early letters of
the alphabet (a, b, c...) at the top and the later letters (t, u, v...) at the bottom ofthe list.

1. First we need to select all the data so we can begin to sort it. Because each name has
a corresponding score we need to select both columns to preserve the students'
correct scores.
2. Left-click and hold on cell A1 then drag down-right to cell B10 to highlight all the data
for sorting! Your spreadsheet should look like this:

3. Left-click the "sort ascending" button, located near the top, on the shortcut bar (ithas a
blue A on top and a red Z on bottom with a downward pointing arrow).

16
4. Your spreadsheet should now be sorted.

Notice that your column titles (Name and Score) have not been included for sorting
because Excel is smart enough to know that you do not want these special cells (A1 and B1)
included.

Reverse Alphabetical Order (Descending)

The steps for reverse alphabetical order are the same as above, except that you need to
click the "sort descending" button instead.

1. Select the data you wish to sort (left-click in cell A1 and drag down-right to B10)

2. Left-click the "sort descending" button, located near the top, on the shortcut bar (it has
a red Z on top and a blue A on bottom downward pointing arrow).

3. Your spreadsheet should now be sorted in reverse alphabetical order.

Numerical Ordering

If you wanted to instead sort the homework assignments by highest to lowest score you
would follow these steps to use Excel's numeric sorting. The only difference between this
example and our previous examples is which column you start your selection from, so pay
close attention to the first step!

1. Left-click cell B1 and drag down-left to cell A10

2. Left-click the "sort descending" button, located near the top, on the shortcut bar (it has
a red Z on top and a blue A on bottom with a downward pointing arrow).

3. Your Excel data should now look like:

Congratulations, you now know how to sort columns of both numbers and words in Excel!

Generic Formatting in Excel

17
Sometimes you don't have the data set up nice and orderly like our above examples,
which might make using Excel's quick sort buttons to fall flat on their face when attempting to
sort your data. If you would like to access Excel's manual, and much more powerful, sorting
option simply select "Data < Sort..." from the menu bar.

Note: Be sure that you select your data before going to the manual sorting feature.
This will let Excel know which data you want to sort

Excel - If Statement

An If Statement is used in Excel to do certain actions only if something is true. For


example, you might want to print out the message "We are losing money" if total sales for the
quarter are below some amount. Otherwise, you'd just want to print out "We're making
money!"

The IF function lets you do these kinds of value based decisions. This lesson will show
you a couple basic examples of how you can make use of the IF function.

Excel - IF Function

The IF function needs to have some sort of comparison to operate properly. A very
common type of comparison is greater/less than (>/<). These math symbols can be used to
form logical expressions like "A2 < 40000", which in English means "Cell A2 is less than
40000".

Now that logical expression can be either true or false and the IF function lets you do
something for each result. In this little example we will be making our IF function print out
something our boss might say.

Your excel spreadsheet should look like this:

Excel - IF Function's 3 Parts

The IF function has three parts:

1. The comparison you will be doing. We are using A2 < 40000


2. What to do if the If statement is true
3. What to do if the If statement is false

If all that information is confusing to you, don't worry, Excel has a built in wizard to help
you make your own If functions.

1. Go to the Insert menu and choose Function


2. Select the Logical functions from the drop down selector

18
3. Choose the IF function and click OK 4.

5. Put "A2<40000" as the logical expression


6. Put "We are losing money?" as the true value
7. Put "We are making money!" as the false value

8. Press OK

Because our sales were only $30,000 the if statement should be printing out "We are
losing money?"

This isn't good at all, we're going to get fired!

Make Some Accounting Adjustments

Let's make some small accounting changes and up that sales figure to $50,000 and see
what the IF function prints out.

Ah that is much better, now we're making money!

Notice that when the value of A2 was $30,000 it was less than $40,000 and our IF
function was set to print out "We are losing money?" when A2 was less than 40,0000.
However, when we changed the value of A2 to $50,000 the IF statement was now false and it
printed out "We are making money!"

Excel - Drop Down List

Ever wish that you didn't have to type out the same thing over and over again? Well you
can save time by using Excel's drop down list!

Drop Down Preparation

19
Imagine that we are creating an Excel spreadsheet to document our purchases from the
grocery store. For each purchase we want to mark down the name of the food and the type of
the food.

The way a drop down list works in Excel is that it takes values from some place on your
spreadsheet and uses them to populate the options in the list. Lucky for us, the type of food is
a perfect opportunity to use a drop down list!

In cells A1 through A7 enter the type of food that will be used for the drop down list.

Creating a Drop Down List

Now that we have a source for our drop down list, we can create a begin to create our
drop down.

1. Select cells D2 though D20 (We will be creating a drown down list for each cell in this
range)

2. Click the Data menu and select Validation


3. Choose List from the Allow drop down menu

4. Click the Source button that appears to the right of the textfield

5. Select our source cells A1 though A7

6. Press Enter and Click OK

Testing Your Drop Down

All of your cells in the Type column should now have a drop down list. To test to see if
your drop down works, click on cell D2 and then click on the downward facing arrow and see
if all the types of food are available.

Excel Linking

At times you may want to use information that exists in a different Excel file. This use of
external information is referred to as "linking" in Excel. This lesson will show you the basics of
creating workbook links in Excel.

20
Creating Two Files

This example will require that you create two files link1.xls and link2.xls. Let's start with
creating link1.xls.

This is a very simple file and only contains the text "this workbook" in cell A1. Savethis file
as link1.xls.

Now let's make link2.xls.

This worksheet only has one data entry in C1 with the value "has a link". Save this file as
link2.xls in the same directory as link1.xls.

Excel Linking: The Reference

As you can probably tell, we are going to link to the information in our second file so that
our first file has the line "this workbook has a link". The actual link reference is quite
complicated looking, so please take your time to understand each component of the Excel
Link.

There are three major parts that a link must have to be valid:

1. Workbook: This is the filename of your Excel document.


2. Worksheet: This is the worksheet name of your Excel sheet. The default name would
be Sheet1.
3. Cells: The cell(s) which are going to be linked to.

These three parts combine to make a pretty ugly looking blob of text. Using the general
terms from above, this is how a generic link would look.

● =[Workbook.xls]Worksheet!Cells

For our example, the Workbook is link2.xls, the Worksheet is Sheet1 and the cell is
C1. Our link would then be:

1. =[link2.xls]Sheet1!C1
2. Enter this link into cell C1 of link1.xls and hit Return.

3. Your link1.xls file should now properly link to your second file to display "this workbook
has a link".

21
AUTO FILL

You can quickly fill cells with several types of data based on adjacent cells. When you
click in a cell, notice that the lower-right corner is a black square. This is called the
fill handle.

When you point to the fill handle the mouse pointer changes to a black cross. +Click and drag

the black cross to an adjacent cell to fill in the adjacent cell.

Text and numbers are copied to the adjacent cells. The cell references in formulas are
adjusted to reflect the new cell location.

AUTOFILL OPTIONS

The Auto Fill Options button appears just below your filled selection after you fill text or
data in a worksheet. When you click the button, a list appears to give you optionsfor how to fill
the text or data.

The available options depend on the content you are filling and the format of the text or data
you are filling.

FILL SERIES

One of the AutoFill options may be to ‘Fill Series.’ ‘Fill Series’ will continue a series based on
a pattern. For example, if you ‘Fill Series’ from a cell that contains the number 20, the next
filled cell will be 21, the next 22, and so on for the number of cells filled.
This forms a series in the filled cells where each subsequent number is the previous number
plus 1.

Other examples:

Cell filled From Defa Series In Subsequent


ult Cells
1 Copy 1,1,1
cells
Hello Copy Hello, Hello, Hello
cells
9:00 am Fill series 10:00 am, 11:00 am , 12:00 pm
Mon Fill series Tue, Wed, Thu
Monday Fill series Tuesday, Wednesday,
Thursday
Jan Fill series Feb, Mar, Apr
Qtr3 (or Q3 or Fill series Qtr4, Qtr1, Qtr2
Quarter3)
1st Period Fill series 2nd Period, 3rd Period
Product 1 Fill series Product 2, Product 3

NOTE: Days and dates have other fill series available under AutoFill Options.

22
You can also define your own series by setting the series in 2 or 3 cells, select those 2 or 3
cells and fill. For example, if you type 1, 3, 5 in 3 cells and fill from those cells, the subsequent
cells will be 7, 9, 11 and so forth.

Other examples:

Jan, Apr Jul, Oct, Jan


Jan-99, Apr-99 Jul-99, Oct-99, Jan-00
15-Jan, 15-Apr 15-Jul, 15-Oct
1-Jan, 1-Mar 1-May, 1-Jul, 1-Sep
text1, textA text2, textA, text3, textA

Create a custom fill series

You can create a custom fill series for frequently used text entries, such as divisions. This
custom fill series can be created from existing items that you've listed on a worksheet, or you
can type the list from scratch.

1. If you've already entered the list of items you want to use as a series, select the list on
the worksheet.
2. On the menubar, click Tools > Options >Custom Lists tab.
3. Do one of the following:
o To use the selected list, click Import.
o To type a new list, select New list in the Custom lists box, and then type the
entries in the List entries box, beginning with the first entry. Press ENTER
after each entry. When the list is complete, click Add.

Note: A custom list can contain text or text mixed with numbers. To create a custom
list that contains only numbers, such as 0 through 100, first select enough empty cells
to contain the list. On the Format menu, click Cells, and then click the Number tab.
Apply the Text format to empty cells, and then type the list of numbers in the formatted
cells. Select the list and then import the list.

Relative reference versus absolute reference

A reference identifies a cell or a range of cells on a worksheet and tells Microsoft Excel where
to look for the values or data you want to use in a formula. With references, you can use data
contained in different parts of a worksheet in one formula or use the value from one cell in
several formulas.

23
Relative references
A relative cell reference in a formula, such as A1, is based on the relative position of the cell
that contains the formula and the cell the reference refers to. If the position of the cell that
contains the formula changes, the reference is changed. If you copy or fill the formula across
rows or down columns, the reference automatically adjusts. For example, if you copy a
relative reference in cell B2 to cell B3, it automatically adjusts from =A1 to =A2.

Copied or filled formula with relative reference

Absolute references

An absolute cell reference in a formula, such as $A$1, always refer to a cell in a specific
location. If the position of the cell that contains the formula changes, the absolute reference
remains the same. If you copy or fill the formula across rows or down columns, the absolute
reference does not adjust. For example, if you copy an absolute reference in cell B2 to cell
B3, it stays the same in both cells =$A$1.

Copied or filled formula with absolute reference

Mixed references

A mixed reference has either an absolute column and relative row, or absolute row and
relative column. An absolute column reference takes the form $A1, $B1, and so on. An
absolute row reference takes the form A$1, B$1, and so on. If the position of the cell that
contains the formula changes, the relative reference is changed, and the absolute reference
does not change. If you copy or fill the formula across rows or down columns, the relative
reference automatically adjusts, and the absolute reference does not adjust. For example, if
you copy a mixed reference from cell A2 to B3, it adjusts from =A$1 to
=B$1.

Copied or filled formula with mixed reference.

FUNCTIONS

Functions are predefined formulas.

o Function ScreenTips – Start typing a function in a cell and a yellow pop-up screen
tip appears showing all of the arguments for the function. The

24
argument in black is the active argument. In addition, if you point to the function name
in the pop-up, you can link to the Help topic for that function.

o AutoSum on the Toolbar - There is a drop down arrow next to the AutoSum icon on
the Standard toolbar. Click this arrow and a list of the most common functions will be
available for use. You can also go to the Function Wizard for more options by clicking
on ‘More Functions.’.
o Function Wizard – You can now type a natural language query, such as "How do I
determine the monthly payment for a car loan" in the Function Wizard. The Wizard will
return a list of recommended functionsyou can use to accomplish your task.

HELP EXAMPLES
Help has more examples, especially using functions. You can copy and paste many examples
into a spreadsheet for easier understanding and reference. Each help example is preceded by
a link ’How?.’ Click on this link for information on how to copy and paste. Basically, you copy
the whole
example except the column and row headers and paste it into a worksheet.

Formulas

o Formula Auditing Toolbar

* Formula Evaluator - You can see the various parts of a nested formula evaluated in
the order the formula is calculated. Go to the ‘Formula Auditing’ toolbar (TOOLS >
FORMULA AUDITING > SHOW FORMULA AUDITING

TOOLBAR on the menu bar).


Click on

* on the Formula Auditing toolbar will graphically display, or trace, the


relationships between cells and formulas with blue arrows. You can trace theprecedent
cells or the dependent cells.

25
o Watch Window - Keep track of cells and their formulas on the Watch Window toolbar,
even when the cells are out
of view. This moveable toolbar tracks cell properties including workbook, worksheet,
name, cell, value, and formula. To display, click VIEW > TOOLBARS on the menu bar.

Sort

Default sort orders

In an ascending sort, Microsoft Excel uses the following order. (In a descending sort, this sort
order is reversed except for blank cells, which are always placed last.)

Numbers: Numbers are sorted from the smallest negative number to the largest positive
number.

Alphanumeric sort: When you sort alphanumeric text, Excel sorts left to right, character by
character. For example, if a cell contains the text "A100," Excel places the cell after a cell that
contains the entry "A1" and before a cell that contains the entry "A11."

Text and text that includes numbers are sorted in the following order:

0 1 2 3 4 5 6 7 8 9 (space) ! " # $ % & ( ) * , . / : ; ? @ [ \ ] ^ _ ` { | } ~ + < = > A B C D E FG H I


JKLMNOPQRSTUVWXYZ

Apostrophes (') and hyphens (-) are ignored, with one exception: If two text strings are the
same except for a hyphen, the text with the hyphen is sorted last.

Logical values: In logical values, FALSE is placed before TRUE.

Error values: All error values are equal.

Blanks: Blanks are always placed last.

Sort a list

▪ Sort rows in ascending order (A to Z, or 0 to 9) or descending order (Z to A, or 9 to 0)

1. Click a cell in the column you would like to sort by.

2. Click Sort Ascending or Sort Descending on the toolbar.

26
▪ Sort by 2 or 3 columns

1. Click a cell in the list you want to sort.


2. Click Data > Sort on the menubar.
3. In the Sort by and Then by boxes, click thecolumns you want to sort.
4. Select any other sort options you want, and then click OK.

▪ Sort by 4 columns

1. Click a cell in the list you want to sort.


2. Click Data > Sort on the menubar.
3. In the first Sort by box, click the column of leastimportance.
4. Click OK.
5. Click Data > Sort on the menubar.
6. In the Sort by and Then by boxes, click the other 3 columns you want to sort, starting
with the most important.
7. Select any other sort options you want, and then click OK.

▪ Sort rows by months or weekdays

1. Select a cell or range in the list you wantto sort.


2. Click Data > Sort on the menubar.
3. In the Sort by box, click the column youwant to sort.
4. Click Options.
5. Under First key sort order, click the custom sort order you want, and then clickOK.
6. Select any other sort options you want, and then click
OK.









▪ Use your own list as the sort order

1. In a range of cells, enter the values you want to sort by, in the order you want them,
from top to bottom. For example:

High MediumLow

2. Select the range.


3. On the menubar, click Tools > Options >Custom Lists tab.

27
4. Click Import, and then click OK.
5. Select a cell in the list you want to sort.
6. On the Data menu, click Sort.
7. In the Sort by box, click the column you want to sort.
8. Click Options.
9. Under First key sort order, click the custom list you created. For example, click
High, Medium, Low.
10. Click OK.
11. Select any other sort options you want, and then click OK.

Note: You can not use a custom sort order in a Then by box.. The custom sort order applies
only to the column specified in the Sort by box. To sort multiple columns by using a custom
sort order, sort by each column separately. For example, to sort by columns A and B, in that
order, first sort by column B, and then specify the custom sortorder by using the Sort Options
dialog box. Next, sort the list by column A.

▪ Sort columns by rows

Most of the time, you sort rows. This procedure sorts the order of columns.

1. Click a cell in the list you want to sort.


2. Click SORT > DATA on the menubar.
3. Click Options.
4. Under Orientation, click Sort left to right, and then click OK.
5. In the Sort by and Then by boxes, click the rows you want to sort.

Subtotals

Microsoft Excel can automatically calculate subtotals and grand total values in a list. When
you insert automatic subtotals, Excel outlines the list so that you can display and hide the
detail rows for each subtotal.

1. To insert subtotals, you first sort your list so that the rows you want to subtotal are
grouped together. You can then calculate subtotals for any column that contains
numbers.

Be sure to include column headers in your list!

2. Click DATA > SUBTOTALS on the menubar.

28
About statistical analysis tools

Microsoft Excel provides a set of data analysis tools— called the Analysis ToolPak— that
you can use to save steps when you develop complex statistical or engineering analyses.
You provide the data and parameters for each analysis; the tool uses the appropriate statistical
or engineering macro functions and then displays the results in an output table. Some tools
generate charts in addition to output tables.

Related worksheet functions Excel provides many other statistical, financial, and
engineering worksheet functions. Some of the statistical functions are built-in and others
become available when you install the Analysis ToolPak.

Accessing the data analysis tools The Analysis ToolPak includes the tools described
below. To access these tools, click Data Analysis on the Tools menu. If the Data Analysis
command is not available, you need to load the Analysis ToolPak add-inprogram.

Perform a statistical analysis

1. On the Tools menu, click Data Analysis.

If Data Analysis is not available, load the Analysis ToolPak.

1. On the Tools menu, click Add-Ins.


2. In the Add-Ins available list, select the Analysis ToolPak box, and then click
OK.
3. If necessary, follow the instructions in the setup program.
2. In the Data Analysis dialog box, click the name of the analysis tool you want to use,
then click OK.
3. In the dialog box for the tool you selected, set the analysis options you want.

You can use the Help button on the dialog box to get more information about the
options.

Anova

The Anova analysis tools provide different types of variance analysis. The tool to use
depends on the number of factors and the number of samples you have from the populations
you want to test.

Anova: Single Factor This tool performs a simple analysis of variance on data for two or
more samples. The analysis provides a test of the hypothesis that each sample is drawn from
the same underlying probability distribution against the alternative hypothesis that underlying
probability distributions are not the same for all samples. If

29
there were only two samples, the worksheet function, TTEST, could equally well be used.
With more than two samples, there is no convenient generalization of TTEST and the Single
Factor Anova model can be called upon instead.

AVERAGE

Returns the average (arithmetic mean) of the arguments.

Syntax AVERAGE(number1,number2,...)

Number1, number2, ... are 1 to 30 numeric arguments for which you want theaverage.

Remarks

● The arguments must either be numbers or be names, arrays, or references thatcontain


numbers.
● If an array or reference argument contains text, logical values, or empty cells, those
values are ignored; however, cells with the value zero are included.

When averaging cells, keep in mind the difference between empty cells and those
containing the value zero, especially if you have cleared the Zero values check box on the
View tab (Options command, Tools menu). Empty cells are not counted, but zero values are.

Example

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A
1 Data
2 10
3 7
4 9

30
5 27
62

Formula Description (Result)


=AVERAGE(A2:A6) Average of the numbers above (11)
=AVERAGE(A2:A6, 5) Average of the numbers above and 5 (10)

STDEVA

Estimates standard deviation based on a sample. The standard deviation is a measure of


how widely values are dispersed from the average value (the mean). Text and logical values
such as TRUE and FALSE are included in the calculation.

Syntax STDEVA(value1,value2,...)

Value1, value2, ... are 1 to 30 values corresponding to a sample of a population.


You can also use a single array or a reference to an array instead of arguments separated by
commas.

Remarks

● STDEVA assumes that its arguments are a sample of the population. If your data
represents the entire population, you must compute the standard deviation using
STDEVPA.
● Arguments that contain TRUE evaluate as 1; arguments that contain text or FALSE
evaluate as 0 (zero). If the calculation must not include text or logical values, use the
STDEV worksheet function instead.
● The standard deviation is calculated using the "unbiased" or "n-1" method.
● STDEVA uses the following formula:

where x is the sample mean AVERAGE(value1,value2,…) and n is the sample


size.

Example

Suppose 10 tools stamped from the same machine during a production run are collected
as a random sample and measured for breaking strength.

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help


3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu.

31
NPV

Calculates the net present value of an investment by using a discount rate and a series of
future payments (negative values) and income (positive values).

Syntax NPV(rate,value1,value2, ...)

Rate is the rate of discount over the length of one period.

Value1, value2, ... are 1 to 29 arguments representing the payments and income.

● Value1, value2, ... must be equally spaced in time and occur at the end of eachperiod.
● NPV uses the order of value1, value2, ... to interpret the order of cash flows. Be sure to
enter your payment and income values in the correct sequence.
● Arguments that are numbers, empty cells, logical values, or text representations of
numbers are counted; arguments that are error values or text that cannot be translated
into numbers are ignored.

32
● If an argument is an array or reference, only numbers in that array or reference are
counted. Empty cells, logical values, text, or error values in the array or reference are
ignored.

Remarks

● The NPV investment begins one period before the date of the value1 cash flow and
ends with the last cash flow in the list. The NPV calculation is based on future cash
flows. If your first cash flow occurs at the beginning of the first period, the first value
must be added to the NPV result, not included in the values arguments. For more
information, see the examples below.
● If n is the number of cash flows in the list of values, the formula for NPV is:
● NPV is similar to the PV function (present value). The primary difference between PV
and NPV is that PV allows cash flows to begin either at the end or at the beginning of
the period. Unlike the variable NPV cash flow values, PV cash flows must be constant
throughout the investment. For information about annuities and financial functions, see
PV.
● NPV is also related to the IRR function (internal rate of return). IRR is the rate forwhich
NPV equals zero: NPV(IRR(...), ...) = 0.

Example 1

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A B
Data Description
1 10% Annual discount rate
2 -10,000 Initial cost of investment one year from today
3 3,000 Return from first year
4 4,200 Return from second year
5 6,800 Return from third year
6 Formula Description (Result)
=NPV(A2, A3, A4, A5, A6) Net present value of this investment (1,188.44)

33
In the preceding example, you include the initial $10,000 cost as one of the values,
because the payment occurs at the end of the first period.

Example 2

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A B
Data Description
Annual discount rate. This might represent the rate of inflation or the
8%
interest rate of a competing investment.
1 -40,000 Initial cost of investment
2 8,000 Return from first year
3 9,200 Return from second year
4 10,000 Return from third year
5 12,000 Return from fourth year
6 14,500 Return from fifth year
7 Formula Description (Result)
8 =NPV(A2,
Net present value of this investment (1,922.06)
A4:A8)+A
3 Net present value of this investment, with a loss in the sixth year of
=NPV(A2, 9000 (-3,749.47)
A4:A8,
-9000)+A3

In the preceding example, you don't include the initial $40,000 cost as one of the values,
because the payment occurs at the beginning of the first period.

IRR

Returns the internal rate of return for a series of cash flows represented by the numbers
in values. These cash flows do not have to be even, as they would be for anannuity. However,
the cash flows must occur at regular intervals, such as monthly or annually. The internal rate
of return is the interest rate received for an investment
34
consisting of payments (negative values) and income (positive values) that occur at regular
periods.

Syntax IRR(values,guess)

Values is an array or a reference to cells that contain numbers for which you want to
calculate the internal rate of return.

● Values must contain at least one positive value and one negative value to calculate the
internal rate of return.
● IRR uses the order of values to interpret the order of cash flows. Be sure to enter your
payment and income values in the sequence you want.
● If an array or reference argument contains text, logical values, or empty cells, those
values are ignored.

Guess is a number that you guess is close to the result of IRR.

● Microsoft Excel uses an iterative technique for calculating IRR. Starting with guess,
IRR cycles through the calculation until the result is accurate within 0.00001 percent. If
IRR can't find a result that works after 20 tries, the #NUM!error value is returned.
● In most cases you do not need to provide guess for the IRR calculation. If guess is
omitted, it is assumed to be 0.1 (10 percent).
● If IRR gives the #NUM! error value, or if the result is not close to what youexpected, try
again with a different value for guess.

Remarks

IRR is closely related to NPV, the net present value function. The rate of return calculated
by IRR is the interest rate corresponding to a 0 (zero) net present value. The following formula
demonstrates how NPV and IRR are related:

NPV(IRR(B1:B6),B1:B6) equals 3.60E-08 [Within the accuracy of the IRR calculation, the
value 3.60E-08 is effectively 0 (zero).]

Example

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.

35
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A B
Data Description
-70,000 Initial cost of a business
12,000 Net income for the first year
15,000 Net income for the second year
18,000 Net income for the third year
21,000 Net income for the fourth year
26,000 Net income for the fifth year
Formula Description (Result)
=IRR(A2:A6) Investment's internal rate of return after four years (-2%)
7
=IRR(A2:A7) Internal rate of return after five years (9%)
=IRR(A2:A4,-10 To calculate the internal rate of return after two years, you need to
%) include a guess (-44%)

TODAY

Returns the serial number of the current date. The serial number is the date-time code
used by Microsoft Excel for date and time calculations. If the cell format was General before
the function was entered, the result is formatted as a date.

Syntax TODAY( )

Remark

Excel stores dates as sequential serial numbers so they can be used in calculations.
By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448
because it is 39,448 days after January 1, 1900. Microsoft Excel for the Macintosh uses a
different date system as its default.

NOW

Returns the serial number of the current date and time. If the cell format was
General before the function was entered, the result is formatted as a date.

Syntax NOW( )

Remarks

36
● Microsoft Excel stores dates as sequential serial numbers so they can be used in
calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is
serial number 39448 because it is 39,448 days after January 1, 1900. Microsoft Excel
for the Macintosh uses a different date system as its default.

● Numbers to the right of the decimal point in the serial number represent the time;
numbers to the left represent the date. For example, the serial number .5 represents
the time 12:00 noon.
● The NOW function changes only when the worksheet is calculated or when a macro
that contains the function is run. It is not updated continuously.

Insert the current date and time in a cell

Insert a static date or time

Current date Select a cell and press CTRL+;

Current time Select a cell and press CTRL+SHIFT+;

Current date and time Select a cell and press CTRL+; then SPACE then
CTRL+SHIFT+;

Insert a date or time whose value is updated

Use the TODAY and NOW functions to do this task.

Worksheet example

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A B
1 Formula Description (Result)
2 =TODAY() Current date (varies)
3 =NOW() Current date and time (varies)

37
Note The NOW() and TODAY() functions change only when the worksheet is calculated
or when a macro that contains the function is run. They are not updated continuously. The date
and time used are taken from the computer's system clock.

Add dates

Add a number of days to a date

Use the addition (+) operator to do this task.

Worksheet example

The example may be easier to understand if you copy it to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.

Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A B
Date Days to add
6/9/2007 3
1 =TODAY() 5
2 12/10/2008 54
3 Description (Result)
Formul
a
4 =A2+B2 Add 3 days to 6/9/2007 (6/12/2007)
=A3+B3 Add 5 days to the current day (varies)
=A4+B4 Add 54 days to 12/10/2008 (2/2/2009)

Add a number of months to a date

Use the DATE, YEAR, MONTH, and DAY functions to do this task.

Worksheet example

This example can be copied on to a blank worksheet.

1. Create a blank workbook or worksheet.


2. Select the example in the Help topic. Do not select the row or column headers.
38
Selecting an example from Help

3. Press CTRL+C.
4. In the worksheet, select cell A1, and press CTRL+V.
5. To switch between viewing the results and viewing the formulas that return the results,
press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and
then click Formula Auditing Mode.

A B
Date Months to add
6/9/2007 3
9/2/2007 5
1
12/10/2008 25
2
Formula Description (Result)
3
=DATE(YEAR(A2),MONTH(A2)+B2,DAY(A2)) Add 3 months to 6/9/2007 (9/9/2007)
4
=DATE(YEAR(A3),MONTH(A3)+B3,DAY(A3)) Add 5 months to 9/2/2007 (2/2/2008)
Add 25 months to 12/10/2008
=DATE(YEAR(A4),MONTH(A4)+B4,DAY(A4))
(1/10/2011)

Charts

Charts are visually appealing and make it easy for users to see comparisons, patterns, and
trends in data. And, a chart is linked to the worksheet data it's created from and is updated
automatically when you change the worksheet data.

To create a chart, click Chart Wizard on the toolbar. There are 4 steps. Some of the
terms used in the Chart Wizard are indicated in the following diagram:

39
Step 1: Chart Type

Select the type of chart you want.

Note the ‘Press and Hold to View Sample’ button!

Step 2: Chart Source Data

Data Range tab = select the range of cells you arecharting

Series tab = differentiate the values you’re charting (series) and the labels

Step 3: Chart Options

Step 4: Chart Location

You can create a chart on its own chart sheetor as an embedded chart on a worksheet.
Either way, the chart is linked to the source data on the worksheet, which means the chart is
updated whenever you update the worksheet data!

40
Embedded charts An embedded chart is considered a graphic object and is saved aspart of
the worksheet on which it is created.

Chart sheets A chart sheet is a separate sheet within your workbook that has its own sheet
name.

Create a macro Record a macro

1. Set the security level to Medium or Low.


1. On the Tools menu, click Options.
2. Click the Security tab.
3. Under Macro Security, click Macro Security.
4. Click the Security Level tab, and then select the security level you wantto use.
2. On the Tools menu, point to Macro, and then click Record New Macro.
3. In the Macro name box, enter a name for the macro.

Notes

1. The first character of the macro name must be a letter. Other characters can be
letters, numbers, or underscore characters. Spaces are not allowed in a macro
name; an underscore character works well as a wordseparator.
2. Do not use a macro name that is also a cell reference or you can get an error
message that the macro name is not valid.
2. If you want to run the macro by pressing a keyboard shortcut key, enter a letter in the
Shortcut key box. You can use CTRL+ letter (for lowercase letters) or CTRL+SHIFT+
letter (for uppercase letters), where letter is any letter key on the keyboard. The
shortcut key letter you use cannot be a number or special character such as @ or #.

Note The shortcut key will override any equivalent default Microsoft Excel shortcut
keys while the workbook that contains the macro is open.

3. In the Store macro in box, click the location where you want to store the macro.

If you want a macro to be available whenever you use Excel, select


Personal Macro Workbook.

4. If you want to include a description of the macro, type it in the Description box.
5. Click OK.
6. If you want the macro to run relative to the position of the active cell, record it using
relative cell references. On the Stop Recording toolbar, click Relative

41
Reference so that it is selected. Excel will continue to record macros with relative
references until you quit Excel or until you click Relative Reference again, so that it is
not selected.
7. Carry out the actions you want to record.
8. On the Stop Recording toolbar, click Stop Recording .

Adjusting Page Setup settings

Before you actually print a worksheet, you should provide Excel information about
margins, headers, footers, and page orientation. You change these settings using the Page
Setup option on the File menu.

The Page Setup dialog box, shown below, has controls for margins, page orientation,
headers and footers and whether gridlines and row and column heading should be printed.

To change page margins

To change your margins, click the Margins tab, and enter the measurement for your
margin, in inches, in the appropriate text box.

To change page orientation

If you want to change the orientation of the page from portrait (vertical) to landscape
(horizontal) click the appropriate button in the Page Orientation section of the Page tab.

To change the header or footer

A header is text that prints at the top of each page. A footer is text that prints at the
bottom of each page. Headers and footers often include the name of the file being printed or
an alternative title, the date, page number, or additional descriptive information. To change
the header or footer, click on the Header /Footer tab in the Page Setup dialog box. The
current header and footer will appear at the top and bottom of the dialog box respectively.
Click the Custom Header or Custom Footer button to change theexisting header or footer.

The header and footer are divided into three sections (left, center and right). Press
<Tab> or <Shift Tab> to move from section of the header or footer to another.

Printing

42
Print preview
Before you actually print, it¹s a good idea to preview your output on the screen.Choose
Print Preview on the File menu to preview your output on screen. Excel¹s Print Preview
screen displays how the document will print on the page, but it is difficult to actually read the
text. Notice that the mouse pointer takes the shape of a magnifying glass. You can enlarge
the printed image by clicking the Zoom button or by using the magnifying glass. Simply click
the magnifying glass on a part of the page you want to enlarge.

The Print Preview screen also has several buttons at the top of the screen for making
adjustments. For example, the Setup button opens the Page Setup dialog boxand the Margins
button lets you change page margin and column widths to fit more information on one page.

If you are satisfied with how the output appears in the Print Preview screen, the Print
button lets you send your output directly to the printer.

Sending your workbook to the printer


Choosing the Print option on the File menu or clicking the Print button on the toolbar
opens a dialog box that lets you change print settings and specify the number of copies to
print. The Print dialog box appears below.

Within the Print dialog box, you can select what you want to print, how many copies and
which pages. For example, if you only want to print the selected cells, or the entire worksheet
you can choose those options.

Querying External Data in Excel

What is External Data

Excel provides the ability to bring data that is "external" to the current workbook into your
workbook. The examples shown here demonstrate how to include data stored in an Access
database into a workbook and manipulate that data in various ways. You can, however, bring
data from any data source that has ODBC capabilities. For example, many accounting
software packages provide ODBC files with which you can query your accounting data into
Excel.

Create a Query Through the User-Interface

Under the Data menu, there is a "Get External Data" option. This is called "Import External
Data" in versions starting with Excel 2002.

43
To start the process of querying an external data source, choose the New Database Query
option. The Choose Data Source dialog appears and is shown below. Also note that Microsoft
Query has started and shows in your Taskbar. Microsoft Query is the program that Excel uses
to query and return the external data.

Note that MS Access Database has been selected. As these examples will be using the
Northwind Sample database that ships with Access, that is the option we want. Also note
there is a checkbox at the bottom of the dialog that allows you to use the Query Wizard. If you
are particularly adept at writing SQL or you are creating a complex query, you may want to
uncheck this box and create the query manually in MS Query. I generally use the wizard even
if I know that I will be modifying the query in MS Query later. With MS Access Database
selected, click on the OK button. You will be presented with a standard file navigation dialog
that allows you to select the database you would like to query.

Navigate to Northwind.mdb and click OK.

This starts the query wizard and shows the first page, Choose Columns. The left listboxshows
all the tables and queries in the database. Unfortunately, it doesn't show which are tables and
which are queries. I advocate a naming convention when using Access where tables start
with Tbl and queries start with Qry, but that's just me.

For this example, choose the Customers table by clicking on the plus sign next to it. This will
expand that table to show the available fields. To include a field in your query, select it and
then click the greater-than-sign button (>). The selected field will be shown in the right listbox.
Double clicking the field name works also.

Select the CustomerID, Company Name and City. Your dialog box should look like this.

If it does, click Next to show the Filter Data dialog.

The Filter Data dialog allows you to set up criteria for your query. If you know SQL, you're
writing the WHERE clause. Setting up criteria is simply limiting the records returned by your
query. Let's limit this query to only those records whose City is equal to Berlin. To do this,
select City in the left hand listbox, select equals in the first combobox and Berlin in the
second. Like this:

You can set criteria for any or all of the fields and you can set multiple criteria for the same
fields. If you use And's and Or's, you may not get the results you want. Generally, the more
complicated your criteria, the better off you are doing it manually in MSQuery. If your screen
looks as above, click Next to show the Sort Order dialog.

44
The Sort Order dialog is pretty straight forward. You can sort by up to three fields in ascending
or descending order. If you don't choose any field, the sort order will be whatever order the
underlying table or query has. Choose to sort by CompanyName in Descending order so that
your screen looks like this:

Click Next to show the Finish dialog.

As its name suggests, the Finish dialog is the last step in the process. You'll notice that you
have three radio button options. You can return the results of the query to Excel, edit the
query further in MSQuery, or create an OLAP cube. OLAP cubes are beyond the scope of this
article, so we'll focus on the first two. Here's what your dialog should look like:

Click Finish to return the data to Excel. Excel will again be in focus and will show the
Returning External Data to Microsoft Excel dialog box, shown here.

The default is to return the data to the existing (active) worksheet at whichever cell was active
when you started the process. The "marching ants" are circling the cell shown in the refedit
control (G7, in this case). Change it to A1, and click OK. You can change the query table
properties via the Properties button, but it's just as easy to change them once the data is in
Excel. Now your spreadsheet will look like this:

That's right, one whole record. Woo hoo! That tells us that the Customers table in the
Northwind database has one record whose City is Berlin.

45
Microsoft Excel - Unit-II
Advanced Excel

Creating Pivot Tables

A PivotTable is a powerful tool to calculate, summarize, and analyze data that lets you see
comparisons, patterns, and trends in your data.

PivotTables work a little bit differently depending on what platform you are using to runExcel.
1. Select the cells you want to create a PivotTable from.

Note: Your data should be organized in columns with a single header row.

2. Select Insert > PivotTable.

3. This will create a PivotTable based on an existing table or range.

4. Choose where you want the PivotTable report to be placed. Select New Worksheet to
place the PivotTable in a new worksheet or Existing Worksheet and select where you
46
want the new PivotTable to appear.

5. Click OK

Pivot Tables from other sources

By clicking the down arrow on the button, you can select from other possible sources for your
PivotTable. In addition to using an existing table or range, there are three other sources you
can select from to populate your PivotTable.

Building out your Pivot Table

1. To add a field to your PivotTable, select the field name checkbox in the
PivotTables Fields pane.

Note: Selected fields are added to their default areas: non-numeric fields are added
to Rows, date and time hierarchies are added to Columns, and numeric fields are
added to Values.

47
2. To move a field from one area to another, drag the field to the target area.

Macros - Relative Reference

We have two options to refer to a cell in excel VBA Absolute references and Relative
references. Default Excel records macro in Absolute mode.

We select a cell “A1”, turn on “Use Relative Reference” and record a macro to type some text
in cells B2:B4.

48
Since we turn on the “Relative reference” option. Macro considers the number of rows and
number of columns from active cells. In our example, we select cell A1 and start type B2
which is to move one column and one row from A1 (Active cell).

Implementation:
Follow the below steps to implement relative reference in Excel Macros:

Step 1: Open Excel and Select Cell “A1”.

Step 2: Go to “Developer” Tab >> Press “Use Relative References” >> Click “Record Macro” .

Step 3: Enter the Macro name “relativeReference” and Press “OK”.

49
Step 4: Type “Australia” in cell B2 Step 5: Type “Brazil” in cell B3 Step 6: Type “Mexico” in cell

B4

Step 7: Select cell B5 and Press “Stop Recording”

50
VBA Code (Recorded):

Sub relativeReference()

ActiveCell.Offset(1, 1).Range("A1").Select ActiveCell.FormulaR1C1 = "Australia"

ActiveCell.Offset(1, 0).Range("A1").Select ActiveCell.FormulaR1C1 = "Brazil"

ActiveCell.Offset(1, 0).Range("A1").Select ActiveCell.FormulaR1C1 = "Mexico"

ActiveCell.Offset(1, 0).Range("A1").Select

End Sub

51
Step 8: You just delete the contents in cells B2:B4, Select Cell B1.

Step 9: Go to View >> Macros >> View Macros – to popup Macro dialog box [keyboard
shortcut – Alt+F8].

Step 10: Select Macro from list (eg. relativeReference) and Press “Run”.

Output:

52
The active cell is B1 and run the macro. So, the outputs (C2:C4) are placed one row and one
column from the active cell B1.

Macros - Absolute Reference

Excel macros can be recorded either with absolute references or relative references. A macro
recorded with absolute references places the recorded steps exactly in the cells where it was
recorded, irrespective of the active cell. On the other hand, a macro recorded with relative
references can perform the recorded tasks at different parts on theworksheet.

53
To record a macro with absolute references, you have to ensure that the macro is being
recorded starting from the cell where the steps have to start. This means, in the case of the
example given in the previous section, you need to do the following −

● Start recording the macro.


● Create a new worksheet.
● Click in any cell other than B2 in the new worksheet.
● Click in the cell B2.
● Continue recording the macro.

This will create a new worksheet for every new report and get the report format placed in the
cell B2 every time you run the macro.

Note − The first three steps given above are essential.

● If you do not create a new worksheet, when you run the macro, it places whatever you
recorded on the same worksheet at the same place. This is not what you want. You
need to have every report on a different worksheet.
● If you do not click in a different cell at the beginning of the recording, even if the active
cell is B2, Excel places the recorded steps in the active cell. When you run the macro,
it will place the recorded report format at any part of the worksheet based on the active
cell. By explicitly clicking in a cell other than B2 and then the cell B2, you are telling
the recorder to always place your macro steps in the cell B2.

You can start recording the macro with the Record Macro command on the Ribbon under the
VIEW tab → Macros. You can also click the Start Recording Macro button present on the left
side of the Excel taskbar.

● Start recording the macro. The Record Macro dialog box appears.
● Give a meaningful name to identify the macro as a report of a particular project.

54
● Select This Workbook under Store macro in, as you will produce reports from this
specific workbook only.
● Give a description to your macro and click OK.

Your macro starts recording.

● Create a new worksheet. This ensures your new report will be on a newworksheet.
● Click in any cell other than B2 in the new worksheet.
● Click in the cell B2. This ensures that the macro places your recorded steps in B2
always.
● Create the format for the report.
● Fill in the static information for the project report.
● Place = TODAY () in C3 and = C14/C12 in the cell C15.
● Format the cells with dates.

Stop recording the macro.

55
You can stop recording the macro either with the Stop Recording command on the Ribbon
under VIEW tab → Macros or by clicking the Stop Recording Macro button present on the left
side of the Excel taskbar.

Your Project Report macro is ready. Save the workbook as a macro-enabled workbook (with
.xlsm extension).

Running a Macro

56
You can generate any number of reports in a few seconds just by running the macro.

● Click the VIEW button on the Ribbon.


● Click Macros.
● Select View Macros from the dropdown list. The Macro dialog box appears.
● Click the macro Report_ProjectXYZ.
● Click the Run button.

A new worksheet will be created in your workbook, with the report stencil created in it in cell
B2.

57
Microsoft Access - Unit-I
Microsoft Access - Introduction

Microsoft Access was created to help people efficiently store and retrieve all types of
information. Microsoft Access users store data ranging from customer satisfaction to monthly
sales to the annual rainfall in the Sahara Desert.

If you have data that can be measured or typed, chances are Microsoft Access will be a
great solution for you to store your information.

Microsoft Access - Overview

Microsoft Access stores information in what is called a database. For now it is good
enough to know that your data is put into a database and not worry about the details. We will
be explaining databases and other key Access elements in a later lesson.

There are four major steps to using Microsoft Access:

1. Database Creation: Create your Microsoft Access database and specify what kind of
data you will be storing. A retail business might create a database to store all their
sales information (i.e. items sold, customer, employee, commission, etc)
2. Data Input: After your database is created the data the store gathers every business
day can be entered into the Access database.
3. Query: This is a fancy term to basically describe the process of retrieving information
from the database.
4. Report(optional): Information from the database is organized in a nice presentation
that can be printed in an Access Report.

Tizag's Microsoft Access tutorial will guide you through each of these steps and teach you
some nifty tips and tricks along the way. If you are ready to learn more about Access please
continue.

Access Database: Overview

The building block of Microsoft Access is the database. If you have never heard this term
before, don't worry about it because we're going to tell you all about it!

The name database is actually a very descriptive name. The database is two things in
one:

● Data...: A place to store your data. This data could be a record of sales, employees,
salaries, or anything else.
● ...base: It is the basic building block that many other features in Access use tofunction.
With a properly created database you can create informative reports about the data,
custom charts to visually display values, and create queries.

58
These items will all be covered in more detail later. Without a database filled with data
you can do...nothing.

A database is a little bit more complex then some think it should be. You cannot enter
data into a database without first creating a table. A table belongs to a database and it is in
these tables that you enter information. We will be discussing tables in the next lesson!

A Real Database Example

People use Access for various reasons, but let's assume someone named Bob is using it
to store information about Bob's Shoe Store. Bob gathers raw information about shoes sold
from a cash register then he manually types this data into Access. Now the tricky part, of
course, is where does he enter this data?

Well, before Bob can dive right into the inputting data, he must first create a Access
Database that will hold his information. It's time for Bob to learn some Access (and you too)!

Creating an Access Database

Bob wants to store information in Access, but doesn't know how many databases he
needs to create!

Although you may require many databases in the future, it is usually sufficient to have one
database per project. This means Bob should have one database for his business, but would
need a separate database if he wanted to store his family's information.

To create a new database in Access follow these steps:

1. Start Access
2. From the menu choose File < New
3. The "New File" side bar will be displayed on the right-hand side of the screen

59
4. Left-click the option "Blank database...", which will then ask you to name your
database. Helpful Hint: Access databases are saved with the .mdb extension.
5. Name your file and press Create. This will automatically save your blank database, so
remember where you put it!

6. The Access Database interface should now be displayed and you are well on your way
to learning Access!

Now that the database has been created we can begin to create our first Access Table. A
table resides within a database and holds information specific to a certain area. We will talk
more about this in the next lesson, Access Tables.

Access Tables

Now that Bob has created his Access Database he can now make a table. A table is
where data is stored and a table lives within a database. Without a database there can be no
table!

A table in Access is quite different then a table in real life. Instead of having wooden legs
and being used for meals, Access Tables are a grid made up of rows and columns. Here's an
example of a table in Access:

60
There are for key components we want you to learn right now:

1. tbl_Sales: The name of our table is the example is "tbl_Sales". Note that we could
have simply called our sales table Sales, but by including a prefix tbl_ there is
absolutely no confusion and is a great Access habit to pick up!
2. Columns: A column is one vertical section of the table (i.e. up-and-down sections).
The vertical columns have their label at the top and these labels should describe the
type of information that will be stored. The columns in this table are: Employee,
Product, Price and SaleNumber.
3. Rows: A row is one horizontal segment of the table (i.e. left-to-right sections). One
record takes up exactly one row. For example, in this table one sale at Bob's Shoe
Store was a pair of slippers, which sold for $5.00. This record was entered left-to-right
as follows: Employee-Bob, Product-Slipper, Price-$5.00,
SaleNumber-3.
4. Cells: A cell is simply the intersection of a row and a column. Can you find the cell that
contains the value $150.00? Which row and column intersected at this cell? When you
enter information into Access it will often be one cell at a time!

These definitions may seem confusing at first and if that is the case, please read through
this lesson, play around in Access then revisit this page to seem if it is starting to make more
sense. If you stick with it you'll be amazed at how much you can learn!

Now that we've covered the basics of Access Tables let's actually create one!

Creating an Access Table

When you create a table in Access you have to know what the table will store and what
format that information will be in. For example if you wanted to store the product identification
numbers involved in a sale, then you might label that column "ProductID" and specify that only
numbers should be stored for that column.

We'll be creating the table tbl_Sales that you saw above, but remember this is only the
table creation stage and we will not be entering data just yet!

1. With the Tables object tab selected, double-click the "Create table in Designview"

61
2. This will bring up the Table Design View

3. There are three columns here that should be explained in detail:


o Field Name: This is where you type the name for your column. A common
practice is to make it one word and to use capitalization for multiple words
squished into one (e.g. SaleNumber)
o Data Type: This column is where you specify the type of data that will be
stored. If you are storing money then select Currency. The most common types
of data are: Text, Number, Currency and Date/Time.
o Description: Here you can type optional notes to remind yourself or provide
useful information for others who might be viewing this file later.
4. The first column in our tbl_Sales example was Employee, so let's enter in Employee
in the Field Name column and choose Text from the Data Type column. If click inside
the Data Type column you will see that it is actually a drop down select box with many
options to choose from. Select the Text option.

5. Enter the following information for our remaining three columns of tbl_Sales:
o Field Name: Product, Data Type: Text
o Field Name: Price, Data Type: Currency
o Field Name: SaleNumber, Data Type: Number

62
6. Before we are finished here, we need to make a Primary Key. A primary key is
restriction that we place on a column stating that there can be no duplicate values in
that column. We will be talking about keys later, but for now right-click in the
SaleNumber row and choose Primary Key from the pop-up menu.

7. We have finished our table's outline so click the X in the top right to close the design
view (don't close Access, just the Design Window).

This will also bring up a prompt to name your Access Table.


8. Click yes and enter "tbl_Sales" for your table's name.

Although this process of creating an Access table might seem overly complicated, with
time you'll be able to create and edit existing tables very quickly. Feel free to revisit this page if
you are having trouble creating an Access table.

The Next Step: Entering Data (Records)

People use Access for various reasons, but let's assume someone named Bob is using it
to store information about Bob's Shoe Store. Bob gathers raw information about shoes sold
from a cash register then he manually types this data into Access. Now the tricky part, of
course, is where does he enter this data?

63
Well, before Bob can dive right into the inputting data, he must first create a Access
Database that will hold his information. It's time for Bob to learn some Access (and you too)!

Creating an Access Database

Now that we have completed the construction of our table we can finally begin to enter in
our sales information. The next lesson will talk you through the process of entering data into
an Access table.

Access Records

With our sales table created we can begin to enter our gathered sales data from Bob's
Shoe Store. A record is simply one entry in a table. You enter data into a table from left-to-right
and you can only enter one record per row.

To begin entering records, double-click the table you want to add records to.

1. Double-click the table tbl_Sales

2. This brings up the Table Window and you can see that our table contains no data, yet.

3. Bob's five sales are as follows (note: Bob is currently the only "employee"):
1. Sneaker - $40
2. Sneaker - $60
3. Slipper - $5
4. Heel - $12
5. Dress - $150
4. Enter the information for Bob's first sale as follows:

64
1. Employee: Bob
2. Product: Sneaker
3. Price: $40
4. SaleNumber: 1

2. Enter the remaining four sales so that your table looks like:

3. You're done entering the data! Close the table and get ready for the next lesson!

Adding records is pretty easy and you would hope so because you will probablyspend the
bulk of your time in Access simply doing data entry into your Access databases.

Having our data in place, we can now begin to do some basic Access Queries to get
useful information from our table. The next lesson will give a basic overview of what a query is
and how to use them.

Create a filter (MDB)


There are four methods you can use to filter records in a form or datasheet: Filter By
Selection, Filter By Form, Filter For Input, and Advanced Filter/Sort. You can also filter
records in a data access page.

Filter records by selecting values in a form or datasheet (Filter By Selection)

1. In a field on a form, subform, datasheet, or subdatasheet, find one instance of the


value you want records to contain in order to be included in the filter's results.
2. Select all or part of a value in a field by doing one of the following:

65
Note How you select the value determines what records the filter returns.
Find records in which the entire contents of that field match the selection o Select the entire
contents of a field or place the insertion point in a field
without selecting anything.

For example, select the value "Berlin" in the City field to return all records with Berlin as the city.

Find records in which the value in that field starts with the same characters you selected.

Select part of a value starting with the first character in a field.

For example, Select only "Fran" in the CompanyName field with thevalue "France restauration" to
return all records that have a company name starting with "Fran," such as "Franchi S.p.A." and
"Frankenversand".

Find records in which all or any part of the value in that field contains thesame characters you selected.

Select part of a value starting after the first character in a field.

Select the letters "Del " in the CompanyName field with the value "Old World Delicatessen" to return all
records that have "del" anywhere in the CompanyName field, such as "Ernst Handel", "Galería del
gastrónomo", and "Que Delícia".

3. Click Filter By Selection on the toolbar.


4. If you want to refine your search, you will need to reset the filter to show all of the
records and then repeat steps 2 and 3. To reset the filter, click Remove Filter on the
toolbar.

Note You can also filter for records that do not have a certain value. After selecting a
value, right-click it, and then click Filter Excluding Selection.

Sort records
Sort records in Form view or Datasheet view

1. Click the field you want to use for sorting records. To sort records in a subform, click
the field you want to sort. To sort records in a subdatasheet, display the subdatasheet
by clicking its expand indicator, and then click the field you want to sort.

66
2. Click Sort Ascending or Sort Descending .

Note In a form, you can sort on only one field at a time. In Datasheet view, when you sort
the subdatasheet for one record, Microsoft Access sorts all the subdatasheets at that level. In
a datasheet or subdatasheet, you can select two or more adjacent columns at the same time,
and then sort them. Access sorts records starting with the leftmost selected column. When
you save the form or datasheet, Access saves thesortorder.

Sort records by using the design grid

1. Open a query in Design view or display the Advanced Filter/Sort window for a table,
query, or form.
2. To sort on more than one field, first arrange the fields in the design grid in the order
you want the sorts performed. Access sorts on the leftmost field first, then on the next
field to the right, and so on. For example, to sort on the LastName field first and then
on the FirstName field, the LastName field must be to the left of the FirstName field in
the grid.
3. In the Sort cell for each of the fields you want to sort on, click an option.
4. To see the results of the query, click View on the toolbar.

Sort records in a reportSpecify a sort order

1. Open the report in Design view.


2. Click Sorting And Grouping on the toolbar to display the Sorting AndGrouping box.
3. In the first row of the Field/Expression column, select a field name, or type an
expression.

The field or expression in the first row is the first sorting level (the largest set). The
second row is the second sorting level, and so on.

Note When you fill in the Field/Expression column, Microsoft Access sets the
Sort Order to Ascending.

Notes

● You can sort on up to 10 fields or expressions in a report.


● The Customer Labels report in the Northwind sample database sorts records by the
values in three fields. To view this report, point to Sample Databases on the Help
menu, click either Northwind Sample Database or Northwind Sample Access
Project, and then open the Customer Labels report in Design view.

Reapply an inherited sort order

1. Open the report in Design view, or if the report is already open, make sure it is
selected.

67
2. Click Properties on the toolbar to display the report's property sheet.
3. In the OrderByOn property box, click Yes to reapply it.

Note If you specify a sort order in a report wizard or in the Sorting And Grouping
dialog box in report Design view, it overrides the inherited sort order.

68
Microsoft Access - Unit-II

Create a macro
You can create a macro to perform a specific action or a macro group to perform a series
of actions.

Create a macro

1. In the Database window, click Macros under Objects.


2. Click the New button on the Database window toolbar.
3. Add an action to the macro.

How?

1. In the Macro window, click the first empty row in the Action column. If you want
to insert an action between two action rows, click the selector for the action row
just below the row where you want to insert the new action, and then click
Insert Row on the toolbar.
2. In the Action column, click the arrow to display the action list.
3. Click the action you want to use.
4. In the lower part of the window, specify arguments for the action, if any are
required. For action arguments whose settings are a database object name,
you can set the argument by dragging the object from the Database window to
the action's Object Name argument box.
5. Type a comment for the action. Comments are optional.
4. To add more actions to the macro, move to another action row and repeat step 3.
Microsoft Access carries out the actions in the order you list them.

Import or link data from a spreadsheet

Before you proceed, make sure that the data in the spreadsheet is arranged in an
appropriate tabular format, and the spreadsheet has the same type of data in each field
(column) and the same fields in every row.

1. Open a database, or switch to the Database window for the open database.
2. Do one of the following:
o To import a spreadsheet, on the File menu, point to Get External Data, and
then click Import.
o To link a spreadsheet, on the File menu, point to Get External Data, and then
click Link Tables.
3. In the Import (or Link) dialog box, in the Files of type box, select Microsoft Excel
(*.xls).
4. Click the arrow to the right of the Look in box, select the drive and folder where the
spreadsheet file is located, and then double-click its icon.
5. Follow the directions in the Import Spreadsheet Wizard dialog boxes. If you are
importing from a Microsoft Excel version 5.0 or later workbook, then you can

69
import from one worksheet within a workbook. You cannot import from any other
multiple-spreadsheet files, such as Microsoft Excel version 4.0 workbooks. To import
from these files, you must first save each spreadsheet as an individual file.

Notes

● You can import or link all the data from a spreadsheet, or just the data from a named
range of cells. Although you normally create a new table in Microsoft Access for the
data, you can also append the data to an existing table as long as your spreadsheet
column headings match the table's field names.
● Access attempts to assign the appropriate data type to imported fields, but you should
check your fields to make sure that they are set to the data type you want. For
example, in an Access database, a phone number or postal code field might be
imported as a Number field, but should be changed to a Text field in Microsoft Access
because it is unlikely that you will perform any calculations on these types of fields.
You should also check and set field properties, such as formatting,as necessary.

Access Query

As tables grow in size they can have hundreds of thousands of records, which makes it
impossible for the user to pick out specific records from that table. Queries were designed to
combat this problem. With a query you can apply a filter to the table's data, so that you only
get the information that you want.

The tricky part of queries is that you must understand how to construct one beforeyou can
actually use them. This lesson will guide you through the basics of making a couple very
simple Access queries.

Choosing a Table to Query

Before you can create a query you have to navigate to the Query Tab in your Access
database. Select Queries from the Objects Pane.

70
Although you could use the Wizard, we will guide you through the process of creating an
Access query with the "Design view". We feel this is helpful for beginners, so they don't feel
overwhelmed when they need to do something the Wizard doesn't allow them to.

1. Double-click "create Query in Design view"


2. Add the table tbl_Sales

3. Your Query window should now have the tbl_Sales table added to it

You have just completed the setup process for making a query. Every time you make a
query you have to first choose which table(s) you want to select data from. Currently, our
database only has one table, so we don't have a lot of choices here.

Now we can begin to create our custom Access query.

Creating a Custom Query

Bob wants a query that will just return the list of items sold and for how much. He doesn't
care about the sale number or the employee. To make this query we are going to have specify
the fields we want to see and ignore the others.

Access lets you quickly select fields you want to see by a simple drag and drop method.
For ever field that a table has there is an entry in the quick table viewer. Notice that the quick
view of tbl_Sales displays the fields: *, Employee, Product, Price and SaleNumber. Note: The
field * is a wildcard, meaning it will select all the fields if you choose *.

71
We only want Product and Price, so let's start by dragging Product down from tbl_Sales
to the first column. Notice that when you drop the Product field into the first column it
populates two of the fields and checks the "Show" box:

Drag and drop the Price field into the adjoining column and you should have something
like:

That's it! You're done! Close the Query window and save your file query as
qry_ProdSales.

Running Your First Query!

Well you've finished writing the backend for your query, so let's if it works. Double-click
your newly created query and you should see something like this:

72
Basic Query Review

When you want to create a query that just uses a select few fields you can simply drag
and drop these fields in design view. The next lesson will go into much more detail on creating
custom queries, but remember this, you already have the knowledge to write queries in
Access! Pretty impressive!

Access Forms

Access provides an easy way to enter data into your Access tables with forms. In Access
you have the ability to quickly make and customize these data entry forms to streamline the
data input process. Learning how to properly create an Access form will save you a great deal
of time!

Using our previous example, imagine that Bob, from Bob's Shoe Store, has recently hired
someone to enter all the sales data at the end of each business day. The only problem is this
person does not know how to use Access, so Bob needs to make them a custom form in
Access! This lesson will guide you through the process of creating a datainput form in Access

Creating an Access Form

Although we haven't recommended the various wizards that Access had available in the
previous lessons, the form wizard is actually very useful and should save you a bunch of
time! Let's create a simple data input form for the new employee!

1. Navigate to the Forms section in Access

73
2. Double-click "Create form by using wizard"
3. We want all of the fields from tbl_Sales to be included in this form, so first select
tbl_Sales from the drop down box "Tables/Queries"

4. The single right arrow will add one selected field at a time, but we want all the fields.
The shortcut to add every field from a given table or query is to click the double arrow
button. Do that and click Next.

5. Choose a Columnar layout and press Next


6. Choose any style and press Next (we chose "Sumi Painting")
7. Change the form's title to frm_EmployeeEntry

and click Finish

Open up your form and check it out!

74
Entering Data Using Access Forms

Now that the form has been created, Bob just needs to teach his employee how to enter
in the data. Lucky for Bob it's as easy as one-two-three and won't take him long to bring his
new employee up to speed.

1. Open up frm_EmployeeEntry (easy!)

2. At the bottom of the form is a set of arrows to navigate through the records. To get to
the end of the existing records and begin entering data you need to click the arrow with
an asterisk(*).

3. Clicking that button will bring you to the first blank record, which would be the sixth in
our case. You would then enter all the data for that record and click the right arrow to
advance to the next blank record. After all the new records have been entered, close
the form and pat yourself on the back.

When you enter data into this form it will automatically add it to our existing tbl_Sales
because we specified that table when we created our form. With this form the new employee
will be able to enter data into Bob's existing Access table without ever knowing a thing about
tables!

75
Access Reports

Having all your data stored in Access is great for maintaining a database, but it isn't the
best when you want to share the data or view it away from a computer. The solution to this
problem is to create an Access report that will let you design a ready-to-print document of
your desired database information.

Sticking with our example of business owner Bob, CEO of Bob's Shoe Store, let's explore
how he would go about printing out a sales report that he can peruse on his flight to the
annual Shoe Owner's of the World Convention (SOWC).

Creating an Access Report

Bob wants a report to show the sales for each product, as well as the total sales for his
company. Luckily, because he has all his sales information in an Access database, he can
create this report in about a minute!

Let's explore how you would create this basic sales report in Access.

1. Navigate to the Reports section in Access

2. Double-click "Create report by using wizard"


3. Select the query we created in the Access Query lesson qry_ProdSales and add both
fields to the report.

76
4. Click Next
5. At the grouping step, add the Product field by clicking the right arrow and click
Next

6. At the sorting step, select Price from the drop-down-box then click Summary Options
...

7. Check the Sum box, so the report will include totals for the Price field and click
OK

and click Finish


8. Click Next to advance to the layout options
9. Choose a Stepped layout and a Portrait orientation, then click Next
10. At the Style screen choose Bold and click Next
11. Name the report rpt_Sales and click finish

77
and click Finish

Open up your report and check it out!

Bob can now print out this handy report and review his sales in an easy-to-read fashion,
while away from his computer. If you would like to make any changes to the report just right-
click rpt_Sales and choose the "Design View" option from the popup menu.

78

You might also like