Você está na página 1de 49

If you're creating a worksheet that will require user input and you want to

minimize data entry errors, use Excel's data validation feature to add a
drop-down list. The best part about it is that you don't have to write any
macros.

Data validation is an excellent way to ensure that a cell entry is of the


proper data type (text, number, or date) and within the proper numeric
range. The drop-down list produced with the feature appears when a user
clicks the cell.

Here's how to create a drop-down list:

1. Type the list of valid entries in a single column. If you like, you can hide
this column (select Format, Column, Hide).
2. Select the cell or cells that will display the list of entries.
3. Choose Data, Validation, and select the Settings tab.
4. From the Allow drop-down list, select List.
5. In the Source box, enter a range address or a reference to the items that
you entered in step 1.
6. Make sure the 'In-cell dropdown' box is selected.
7. Click OK.

If your list is short, you can skip step 1 and type the list entries directly in
the Source box in step 5, separating items with a comma.

The Data Validation dialog box has two other tabs. Click Input Message to
add a prompt that will appear when a user selects a cell. Click Error Alert
to specify a custom error message if the user's entry is invalid.

The handy data validation feature suffers from one serious flaw. If you
paste an entry into a cell that uses data validation, the validation isn't
performed. And if you select that cell again, the drop-down list no longer
appears. Fortunately, you can circumvent this problem by protecting the
worksheet: Select Tools, Protection, Protect Sheet.

Excel's conditional formatting feature (available in Excel 97 or later) offers


an easy way to apply special formatting to cells if a particular condition is
met. This feature is even more useful when you understand how to use a
formula in your conditional formatting specification.

The worksheet below shows student grades on two tests. Conditional


formatting highlights students who scored higher on the second test. This
formatting is dynamic; if you change the test scores, the formatting
adjusts automatically.

To apply conditional formatting, select range A2:C15 and choose Format,


Conditional Formatting. The Conditional Formatting dialog box will appear
with two input boxes. In the first box, choose Formula Is, pressTab, and
enter the following formula: =$C2>$B2

Click Format and choose a format to distinguish the cells (the example
uses background shading). Click OK, and the formatting will be applied.

The conditional formatting formula is evaluated for each cell in the range.
The trick here is to use mixed cell references (the column references are
absolute, but the row references are relative). To see how this works,
activate any cell within the range and choose Format, Conditional
Formatting so you can examine the conditional formatting formula for
that cell. You'll find that cell A7, for example, uses this formula: =$C7>$B7
If you use Excel 2007 or later, you may not have discovered the "special"
Font dialog box that's available when you're working with a Text Box or
text in a Shape.

Add a text box and some text, select the text, right-click, and choose Font.
(or press Ctrl+1). Excel displays this Font dialog box that is unlike its other
Font dialog boxes.

It has quite a few options that aren't normally available -- and even more
are in the Character Spacing tab. Here's an example of some unusual text
effects.
Count and Sum Functions
Count | Countif | Countifs | Sum | Sumif | Sumifs
The most used functions in Excel are the functions that count and sum. You can count and sum based on
one criteria or multiple criteria.
Count
To count the number of cells that contain numbers, use the COUNT function.

Countif
To count cells based on one criteria (for example, higher than 9), use the following COUNTIF function.

Countifs
To count cells based on multiple criteria (for example, green and higher than 9), use the following
COUNTIFS function.
Sum
To sum a range of cells, use the SUM function.

Sumif
To sum cells based on one criteria (for example, higher than 9), use the following SUMIF function (two
arguments).

To sum cells based on one criteria (for example, green), use the following SUMIF function (three arguments,
last argument is the range to sum).

Sumifs
To sum cells based on multiple criteria (for example, blue and green), use the following SUMIFS function
(first argument is the range to sum).
General note: in a similar way, you can use the AVERAGEIF and AVERAGEIFS function to average cells based
on one or multiple criteria.

Logical Functions
If Function | And Function | Or Function
Learn how to use Excel's logical functions such as the IF, AND and OR function.
If Function
The IF function checks whether a condition is met, and returns one value if TRUE and another value if
FALSE.
1. Select cell C1 and enter the following function.

The IF function returns Correct because the value in cell A1 is higher than 10.

And Function
The AND Function returns TRUE if all conditions are true and returns FALSE if any of the conditions are
false.
1. Select cell D1 and enter the following formula.

The AND function returns FALSE because the value in cell B1 is not higher than 5. As a result the IF function
returns Incorrect.

Or Function
The OR function returns TRUE if any of the conditions are TRUE and returns FALSE if all conditions are false.
1. Select cell E1 and enter the following formula.
The OR function returns TRUE because the value in cell A1 is higher than 10. As a result the IF function
returns Correct.

General note: the AND and OR function can check up to 255 conditions.

Nested If
The IF function in Excel can be nested, when you have multiple conditions to meet. The FALSE value is
being replaced by another IF function to make a further test.
Note: if you have Excel 2016, simply use the IFS function.
1a. If cell A1 equals 1, the formula returns Bad.

1b. If cell A1 equals 2, the formula returns Good.

1c. If cell A1 equals 3, the formula returns Excellent.

1d. If cell A1 equals another value, the formula returns No Valid Score.

Here's another example.

2a. If cell A1 is less or equal to 10, the formula returns 350.


2b. If cell A1 is greater than 10 and less or equal to 20, the formula returns 700.

2c. If cell A1 is greater than 20 and less or equal to 30, the formula returns 1400.

2d. If cell A1 is greater than 30, the formula returns 2000.

Note: to slightly change the boundaries, you might want to use "<" instead of "<=" in your own formula.

This example teaches you how to simulate the roll of two dice in Excel. If you are in a hurry, simply
download the Excel file.
Note: the instructions below do not teach you how to format the worksheet. We assume that you know
how to change font sizes, font styles, insert rows and columns, add borders, change background colors, etc.
1. At the moment, each cell contains the letter l (as in lion). With a Wingdings font style, these l's look like

dots.

2. Enter the RANDBETWEEN function in cell C2.

3. Enter the formula shown below into the yellow cells. If we roll 2, 3, 4, 5 or 6, these cells should contain a
dot.
4. Enter the formula shown below into the red cells. If we roll 4, 5 or 6, these cells should contain a dot.

5. Enter the formula shown below into the blue cells. If we roll 6, these cells should contain a dot.

6. Enter the formula shown below into the gray cell. If we roll 1, 3 or 5, this cell should contain a dot.
7. Copy the range C2:E5 and paste it to the range G2:I5.

8. Change the font color of cell C2 and cell G2 to green (so the numbers are not visible).

9. Click the command button on the sheet (or press F9).

Result.

Cell References
Relative Reference | Absolute Reference | Mixed Reference
Cell references in Excel are very important. Understand the difference between relative, absolute and
mixed reference, and you are on your way to success.
Relative Reference
By default, Excel uses relative reference. See the formula in cell D2 below. Cell D2 references (points to) cell
B2 and cell C2. Both references are relative.
1. Select cell D2, click on the lower right corner of cell D2 and drag it down to cell D5.

Cell D3 references cell B3 and cell C3. Cell D4 references cell B4 and cell C4. Cell D5 references cell B5 and
cell C5. In other words: each cell references its two neighbors on the left.

Absolute Reference
See the formula in cell E3 below.

1. To create an absolute reference to cell H3, place a $ symbol in front of the column letter and row number
of cell H3 ($H$3) in the formula of cell E3.

2. Now we can quickly drag this formula to the other cells.

The reference to cell H3 is fixed (when we drag the formula down and across). As a result, the correct
lengths and widths in inches are calculated.

Mixed Reference
Sometimes we need a combination of relative and absolute reference (mixed reference).
1. See the formula in cell F2 below.
2. We want to copy this formula to the other cells quickly. Drag cell F2 across one cell, and look at the
formula in cell G2.

Do you see what happens? The reference to the price should be a fixed reference to column B. Solution:
place a $ symbol in front of the column letter of cell B2 ($B2) in the formula of cell F2. In a similar way,
when we drag cell F2 down, the reference to the reduction should be a fixed reference to row 6. Solution:
place a $ symbol in front of the row number of cell B6 (B$6) in the formula of cell F2.
Result:

Note: we don't place a $ symbol in front of the row number of B2 (this way we allow the reference to
change from B2 (Jeans) to B3 (Shirts) when we drag the formula down). In a similar way, we don't place a $
symbol in front of the column letter of B6 (this way we allow the reference to change from B6 (Jan) to C6
(Feb) and D6 (Mar) when we drag the formula across).

3. Now we can quickly drag this formula to the other cells.


The references to column B and row 6 are fixed.

Hyperlinks
Existing File or Web Page | Place in This Document
To create a hyperlink in Excel, execute the following steps.
1. On the Insert tab, in the Links group, click Hyperlink.

The 'Insert Hyperlink' dialog box appears.

Existing File or Web Page


To create a link to an existing file or web page, execute the following steps.
1a. To create a link to an existing Excel file, select a file (use the Look in drop-down list, if necessary).

1b. To create a link to a web page, type the Text to display, the Address, and click OK.
Result:

Note: if you want to change the text that appears when you hover over the link, click ScreenTip.

Place in This Document


To create a link to a place in this document, execute the following steps.

1. Click 'Place in This Document' under Link to.

2. Type the Text to display, the cell reference, and click OK.

Result:
Date & Time Functions
Year, Month, Day | Date Function | Current Date & Time | Hour, Minute, Second | Time Function
To enter a date in Excel, use the "/" or "-" characters. To enter a time, use the ":" (colon). You can also enter
a date and a time in one cell.

Note: Dates are in US Format. Months first, Days second. This type of format depends on your windows
regional settings. Learn more about Date and Time formats.
Year, Month, Day
To get the year of a date, use the YEAR function.

Note: use the MONTH and DAY function to get the month and day of a date.

Date Function
1. To add a number of days to a date, use the following simple formula.

2. To add a number of years, months and/or days, use the DATE function.
Note: the DATE function accepts three arguments: year, month and day. Excel knows that 6 + 2 = 8 = August
has 31 days and rolls over to the next month (23 August + 9 days = 1 September).

Current Date & Time


To get the current date and time, use the NOW function.

Note: use the TODAY function to get the current date only. Use NOW()-TODAY() to get the current time
only (and apply a Time format).
Hour, Minute, Second
To return the hour, use the HOUR function.

Note: use the MINUTE and SECOND function to return the minute and second.

Time Function
To add a number of hours, minutes and/or seconds, use the TIME function.

Note: Excel adds 2 hours, 10 + 1 = 11 minutes and 70 - 60 = 10 seconds.

Statistical Functions
Average | Averageif | Median | Mode | Standard Deviation | Min | Max | Large | Small
This chapter gives an overview of some very useful statistical functions in Excel.
Average
To calculate the average of a range of cells, use the AVERAGE function.
Averageif
To average cells based on one criteria, use the AVERAGEIF function. For example, to calculate the average
excluding zeros.

Note: <> means not equal to. The AVERAGEIF function is similar to the SUMIF function.
Median
To find the median (or middle number), use the MEDIAN function.

Check:

Mode
To find the most frequently occurring number, use the MODE function.

Standard Deviation
To calculate the standard deviation, use the STEDV function.
Min
To find the minimum value, use the MIN function.

Max
To find the maximum value, use the MAX function.

Large
To find the third largest number, use the following LARGE function.

Check:

Small
To find the second smallest number, use the following SMALL function.
Check:

Tip: Excel can generate most of these results with the click of a button. Our Descriptive Statistics example
shows you how.

Round
Round | RoundUp | RoundDown
This chapter illustrates three functions to round numbers in Excel. The
ROUND, ROUNDUP and ROUNDDOWNfunction.
Before your start: if you round a number, you lose precision. If you don't want this, show fewer decimal
placeswithout changing the number itself.
Round
1. Round a number to two decimal places.

Note: 1, 2, 3, and 4 get rounded down. 5, 6, 7, 8, and 9 get rounded up. In this example, 114.7211,
114.7221, 114.7231 and 114.7241 get rounded down to 114.72 and 114.7251, 114.7261, 114.7271,
114.7281 and 114.7291 get rounded up to 114.73.
2. Round a number to one decimal place.

3. Round a number to the nearest integer.

4. Round a number to the nearest 10.


5. Round a number to the nearest 100.

RoundUp
The ROUNDUP function always rounds a number up (away from zero). For example, round a number up to
one decimal place.

RoundDown
The ROUNDDOWN function always rounds a number down (toward zero). For example, round a number
down to the nearest integer.

Filter
Filter your Excel data if you only want to display records that meet certain criteria.
1. Click any single cell inside a data set.

2. On the Data tab, in the Sort & Filter group, click Filter.
Arrows in the column headers appear.

3. Click the arrow next to Country.

4. Click on Select All to clear all the check boxes, and click the check box next to USA.

5. Click OK.

Result. Excel only displays the sales in the USA.


6. Click the arrow next to Quarter.

7. Click on Select All to clear all the check boxes, and click the check box next to Qtr 4.

8. Click OK.

Result. Excel only displays the sales in the USA in Qtr 4.

9. To remove the filter, on the Data tab, in the Sort & Filter group, click Clear. To remove the filter and the
arrows, click Filter.

Conditional Formatting
Highlight Cells Rules | Clear Rules | Top/Bottom Rules
Conditional formatting in Excel enables you to highlight cells with a certain color, depending on the cell's
value.
Highlight Cells Rules
To highlight cells that are greater than a value, execute the following steps.

1. Select the range A1:A10.

2. On the Home tab, in the Styles group, click Conditional Formatting.

3. Click Highlight Cells Rules, Greater Than.

4. Enter the value 80 and select a formatting style.

5. Click OK.

Result. Excel highlights the cells that are greater than 80.
6. Change the value of cell A1 to 81.

Result. Excel changes the format of cell A1 automatically.

Note: you can also highlight cells that are less than a value, between a low and high value, etc.

Clear Rules
To clear a conditional formatting rule, execute the following steps.
1. Select the range A1:A10.

2. On the Home tab, in the Styles group, click Conditional Formatting.


3. Click Clear Rules, Clear Rules from Selected Cells.

Top/Bottom Rules
To highlight cells that are above the average of the cells, execute the following steps.

1. Select the range A1:A10.

2. On the Home tab, in the Styles group, click Conditional Formatting.

3. Click Top/Bottom Rules, Above Average.


4. Select a formatting style.

5. Click OK.

Result. Excel calculates the average (42.5) and formats the cells that are above this average.

Note: you can also highlight the top 10 items, the top 10 %, etc. The sky is the limit!

Charts
Create a Chart | Change Chart Type | Switch Row/Column | Legend Position | Data Labels
A simple chart in Excel can say more than a sheet full of numbers. As you'll see, creating charts is very easy.
Create a Chart
To create a line chart, execute the following steps.

1. Select the range A1:D7.


2. On the Insert tab, in the Charts group, click the Line symbol.

3. Click Line with Markers.

Result:
Note: enter a title by clicking on Chart Title. For example, Wildlife Population.

Change Chart Type


You can easily change to a different type of chart at any time.

1. Select the chart.

2. On the Design tab, in the Type group, click Change Chart Type.

3. On the left side, click Column.

4. Click OK.

Result:
Switch Row/Column
If you want to display the animals (instead of the months) on the horizontal axis, execute the following
steps.

1. Select the chart.

2. On the Design tab, in the Data group, click Switch Row/Column.

Result:

Legend Position
To move the legend to the right side of the chart, execute the following steps.

1. Select the chart.

2. Click the + button on the right side of the chart, click the arrow next to Legend and click Right.
Result:

Data Labels
You can use data labels to focus your readers' attention on a single data series or data point.

1. Select the chart.

2. Click a green bar to select the Jun data series.

3. Use your arrow keys to select the population of Dolphins in June (tiny green bar).

4. Click the + button on the right side of the chart and click the check box next to Data Labels.

Result:
Pivot Tables
Insert a Pivot Table | Drag fields | Sort | Filter | Change Summary Calculation | Two-dimensional Pivot
Table
Pivot tables are one of Excel's most powerful features. A pivot table allows you to extract the significance
from a large, detailed data set.
Our data set consists of 213 records and 6 fields. Order ID, Product, Category, Amount, Date and Country.

Insert a Pivot Table


To insert a pivot table, execute the following steps.
1. Click any single cell inside the data set.

2. On the Insert tab, in the Tables group, click PivotTable.

The following dialog box appears. Excel automatically selects the data for you. The default location for a
new pivot table is New Worksheet.

3. Click OK.
Drag fields
The PivotTable Fields pane appears. To get the total amount exported of each product, drag the following
fields to the different areas.
1. Product field to the Rows area.

2. Amount field to the Values area.3. Country field to the Filters area.

Below you can find the pivot table. Bananas are our main export product. That's how easy pivot tables can
be!
Sort
To get Banana at the top of the list, sort the pivot table.

1. Click any cell inside the Sum of Amount column.

2. Right click and click on Sort, Sort Largest to Smallest.

Result.

Filter
Because we added the Country field to the Filters area, we can filter this pivot table by Country. For
example, which products do we export the most to France?

1. Click the filter drop-down and select France.

Result. Apples are our main export product to France.

Note: you can use the standard filter (triangle next to Row Labels) to only show the amounts of specific
products.

Change Summary Calculation


By default, Excel summarizes your data by either summing or counting the items. To change the type of
calculation that you want to use, execute the following steps.

1. Click any cell inside the Sum of Amount column.

2. Right click and click on Value Field Settings.

3. Choose the type of calculation you want to use. For example, click Count.
4. Click OK.

Result. 16 out of the 28 orders to France were 'Apple' orders.

Two-dimensional Pivot Table


If you drag a field to the Rows area and Columns area, you can create a two-dimensional pivot table.
First, insert a pivot table. Next, to get the total amount exported to each country, of each product, drag the
following fields to the different areas.
1. Country field to the Rows area.

2. Product field to the Columns area.

3. Amount field to the Values area.

4. Category field to the Filters area.


Below you can find the two-dimensional pivot table.

To easily compare these numbers, create a pivot chart and apply a filter. Maybe this is one step too far for
you at this stage, but it shows you one of the many other powerful pivot table features Excel has to offer.
Tables
Insert a Table | Sort a Table | Filter a Table | Total Row
Tables allow you to analyze your data in Excel quickly and easily. Learn how to insert, sort and filter a table,
and how to display a total row at the end of a table.
Insert a Table
To insert a table, execute the following steps.

1. Click any single cell inside the data set.

2. On the Insert tab, in the Tables group, click Table.


3. Excel automatically selects the data for you. Check 'My table has headers' and click on OK.

Result. Excel creates a nicely formatted table for you. This may still seem like a normal data range to you
but many powerful features are now just a click of a button away.

Sort a Table
To sort by Last Name first and Sales second, execute the following steps.

1. Click the arrow next to Sales and click Sort Smallest to Largest.

2. Click the arrow next to Last Name and click Sort A to Z.

Result.
Filter a Table
To filter a table, execute the following steps.

1. Click the arrow next to Country and only check USA.

Result.

Total Row
To display a total row at the end of the table, execute the following steps.

1. First, select a cell inside the table. Next, on the Design tab, in the Table Style Options group, check Total
Row.

Result.
2. Click any cell in the last row to calculate the Total (Average, Count, Max, Min, Sum etc.) of a column. For
example, calculate the sum of the Sales column.

Note: in the formula bar see how Excel uses the SUBTOTAL function to calculate the sum. 109 is the
argument for Sum if you use the SUBTOTAL function. Excel uses this function (and not the standard SUM
function) to correctly calculate table totals of filtered tables.

What-If Analysis
Create Different Scenarios | Scenario Summary | Goal Seek
What-If Analysis in Excel allows you to try out different values (scenarios) for formulas. The following
example helps you master what-if analysis quickly and easily.
Assume you own a book store and have 100 books in storage. You sell a certain % for the highest price of
$50 and a certain % for the lower price of $20.
If you sell 60% for the highest price, cell D10 calculates a total profit of 60 * $50 + 40 * $20 = $3800.

Create Different Scenarios


But what if you sell 70% for the highest price? And what if you sell 80% for the highest price? Or 90%, or
even 100%? Each different percentage is a different scenario. You can use the Scenario Manager to create
these scenarios.
Note: You can simply type in a different percentage into cell C4 to see the corresponding result of a
scenario in cell D10. However, what-if analysis enables you to easily compare the results of different
scenarios. Read on.

1. On the Data tab, in the Forecast group, click What-If Analysis.

2. Click Scenario Manager.

The Scenario Manager dialog box appears.

3. Add a scenario by clicking on Add.


4. Type a name (60% highest), select cell C4 (% sold for the highest price) for the Changing cells and click on
OK.

5. Enter the corresponding value 0.6 and click on OK again.

6. Next, add 4 other scenarios (70%, 80%, 90% and 100%).

Finally, your Scenario Manager should be consistent with the picture below:
Note: to see the result of a scenario, select the scenario and click on the Show button. Excel will change the
value of cell C4 accordingly for you to see the corresponding result on the sheet.

Scenario Summary
To easily compare the results of these scenarios, execute the following steps.

1. Click the Summary button in the Scenario Manager.

2. Next, select cell D10 (total profit) for the result cell and click on OK.

Result:

Conclusion: if you sell 70% for the highest price, you obtain a total profit of $4100, if you sell 80% for the
highest price, you obtain a total profit of $4400, etc. That's how easy what-if analysis in Excel can be.

Goal Seek
What if you want to know how many books you need to sell for the highest price, to obtain a total profit of
exactly $4700? You can use Excel's Goal Seek feature to find the answer.
1. On the Data tab, in the Forecast group, click What-If Analysis.

2. Click Goal Seek.

The Goal Seek dialog box appears.

3. Select cell D10.

4. Click in the 'To value' box and type 4700.

5. Click in the 'By changing cell' box and select cell C4.

6. Click OK.

Result. You need to sell 90% of the books for the highest price to obtain a total profit of exactly $4700.
Create a Macro
Developer Tab | Command Button | Assign a Macro | Visual Basic Editor
With Excel VBA you can automate tasks in Excel by writing so called macros. In this chapter, learn how to
create a simple macro which will be executed after clicking on a command button. First, turn on the
Developer tab.

Developer Tab
To turn on the Developter tab, execute the following steps.

1. Right click anywhere on the ribbon, and then click Customize the Ribbon.

2. Under Customize the Ribbon, on the right side of the dialog box, select Main tabs (if necessary).

3. Check the Developer check box.

4. Click OK.
5. You can find the Developer tab next to the View tab.

Command Button
To place a command button on your worksheet, execute the following steps.

1. On the Developer tab, click Insert.


2. In the ActiveX Controls group, click Command Button.

3. Drag a command button on your worksheet.

Assign a Macro
To assign a macro (one or more code lines) to the command button, execute the following steps.

1. Right click CommandButton1 (make sure Design Mode is selected).

2. Click View Code.


The Visual Basic Editor appears.

3. Place your cursor between Private Sub CommandButton1_Click() and End Sub.

4. Add the code line shown below.

Note: the window on the left with the names Sheet1, Sheet2 and Sheet3 is called the Project Explorer. If
the Project Explorer is not visible, click View, Project Explorer. To add the Code window for the first sheet,
click Sheet1 (Sheet1).

5. Close the Visual Basic Editor.

6. Click the command button on the sheet (make sure Design Mode is deselected).

Result:
Congratulations. You've just created a macro in Excel!

Visual Basic Editor


To open the Visual Basic Editor, on the Developer tab, click Visual Basic.

The Visual Basic Editor appears.

Você também pode gostar