You are on page 1of 66

AUGUST 9, 2021

FAST TRACK: EXCEL ADVANCED


TRAINER: SITI SURIANI SHIH OTHMAN
Fast Track Series - Microsoft Office Excel Advanced

Table of Contents
1.0 Using logical functions .................................................................................................................... 1
1.1 The IF function (recap) ................................................................................................................ 1
1.2 Creating nested IF functions ....................................................................................................... 3
1.3 The IFS function .......................................................................................................................... 4
1.4 AND and OR functions................................................................................................................. 6
1.5 Combining logical functions ........................................................................................................ 8
2.0 Working with Lookups .................................................................................................................... 9
2.1 The VLOOKUP function ............................................................................................................... 9
2.2 The HLOOKUP function ............................................................................................................. 14
2.3 INDEX & MATCH........................................................................................................................ 15
3.0 Data Validation ............................................................................................................................. 19
3.1 Using data validation ................................................................................................................ 19
3.2 Setting criteria for entry of text, values and dates .................................................................... 22
3.3 Creating a dropdown list ........................................................................................................... 25
4.0 PivotTables and PivotCharts ......................................................................................................... 28
4.1 Creating and rearranging PivotTables ....................................................................................... 28
4.2 Using the PivotTable toolbar ..................................................................................................... 33
4.3 Creating PivotCharts ................................................................................................................. 34
4.4 Using Slicers to manipulate PivotTables .................................................................................... 36
5.0 Using analytical options ................................................................................................................ 41
5.1 Using Goal Seek......................................................................................................................... 41
5.2 Creating, saving and viewing scenarios ..................................................................................... 45
5.3 Creating single input data tables ............................................................................................... 49
5.4 Creating double input data tables ............................................................................................. 52
6.0 Macros .......................................................................................................................................... 54
6.1 Creating macros ........................................................................................................................ 54
6.2 Using the macro recorder ......................................................................................................... 56

i
Fast Track Series - Microsoft Office Excel Advanced

1.0 Using logical functions


1.1 The IF function (recap)

The IF function checks whether a condition is met, and returns one value if true and another value if
false.

1a. For example, take a look at the IF function in cell B2 below.

Explanation: if the price is greater than 500, the IF function returns High, else it returns Low.

Formula: =IF(A2>500,"High","Low")

1b. The following IF function produces the exact same result.

Note: you can use the following comparison operators: = (equal to), > (greater than), < (less than), >=
(greater than or equal to), <= (less than or equal to) and <> (not equal to).

Formula: =IF(A2<500,"Low","High")

1
Fast Track Series - Microsoft Office Excel Advanced

2. Always enclose text in double quotation marks.

Formula: =IF(A2="USA",5,0)

3a. The formula below calculates the progress between two points in time.

3b. You can use the IF function to display an empty string if the end value hasn't been entered yet (see
row 5).

Explanation: if the end value is not empty (<> means not equal to), the IF function calculates the
progress between the start and end value, else it displays an empty string (two double quotes with
nothing in between).

Formula: =IF(B2<>"",B2-A2,"")

2
Fast Track Series - Microsoft Office Excel Advanced

1.2 Creating nested IF functions

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.

1. For example, take a look at the nested IF formula in cell C2 below.

Explanation: if the score equals 1, the nested IF formula returns Bad, if the score equals 2, the nested
IF formula returns Good, if the score equals 3, the nested IF formula returns Excellent, else it returns
Not Valid.

Formula: =IF(B2=1,"Bad",IF(B2=2,"Good",IF(B2=3,"Excellent","Not Valid")))

2. For example, take a look at the nested IF formula in cell C2 below.

Explanation: if the score is less than 60, the nested IF formula returns F, if the score is greater than or
equal to 60 and less than 70, the formula returns D, if the score is greater than or equal to 70 and less
than 80, the formula returns C, if the score is greater than or equal to 80 and less than 90, the formula
returns B, else it returns A.

Formula: =IF(B2<60,"F",IF(B2<70,"D",IF(B2<80,"C",IF(B2<90,"B","A"))))

3
Fast Track Series - Microsoft Office Excel Advanced

1.3 The IFS function

Use the IFS function in Excel 2016 or later when you have multiple conditions to meet. The IFS function
returns a value corresponding to the first TRUE condition.

Note: if you don't have Excel 2016 or later, you can nest the IF function.

1a. If the value in cell A1 equals 1, the IFS function returns Bad.

1b. If the value in cell A1 equals 2, the IFS function returns Good.

1c. If the value in cell A1 equals 3, the IFS function returns Excellent.

1d. If the value in cell A1 equals another value, the IFS function returns No Valid Score.

Note: instead of TRUE, you can also use 1=1 or something else that is always TRUE.

Formula: =IFS(A1=1,"Bad",A1=2,"Good",A1=3,"Excellent",TRUE,"No Valid Score")

4
Fast Track Series - Microsoft Office Excel Advanced

2a. If the value in cell A1 is less than 60, the IFS function returns F.

2b. If the value in cell A1 is greater than or equal to 60 and less than 70, the IFS function returns D.

2c. If the value in cell A1 is greater than or equal to 70 and less than 80, the IFS function returns C.

2d. If the value in cell A1 is greater than or equal to 80 and less than 90, the IFS function returns B.

2e. If the value in cell A1 is greater than or equal to 90, the IFS function returns A.

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

Formula: =IFS(A1<60,"F",A1<70,"D",A1<80,"C",A1<90,"B",A1>=90,"A")

5
Fast Track Series - Microsoft Office Excel Advanced

1.4 AND and OR functions

Use the IF function in combination with the AND function and the OR function and become an Excel
expert.

1. For example, take a look at the IF function in cell D2 below.

Explanation: the AND function returns TRUE if the first score is greater than or equal to 60 and the
second score is greater than or equal to 90, else it returns FALSE. If TRUE, the IF function returns Pass,
if FALSE, the IF function returns Fail.

Formula: =IF(AND(B2>=60,C2>=90),"Pass","Fail")

2. For example, take a look at the IF function in cell D2 below.

Explanation: the OR function returns TRUE if at least one score is greater than or equal to 60, else it
returns FALSE. If TRUE, the IF function returns Pass, if FALSE, the IF function returns Fail.

Formula: =IF(OR(B2>=60,C2>=60),"Pass","Fail")

6
Fast Track Series - Microsoft Office Excel Advanced

3. For example, take a look at the IF function in cell D2 below.

Explanation: the AND function above has two arguments separated by a comma (Table, Green or
Blue). The AND function returns TRUE if Product equals "Table" and Color equals "Green" or "Blue". If
TRUE, the IF function reduces the price by 50%, if FALSE, the IF function reduces the price by 10%.

Formula: =IF(AND(A2="Table",OR(B2="Green",B2="Blue")),0.5*C2,0.9*C2)

7
Fast Track Series - Microsoft Office Excel Advanced

1.5 Combining logical functions

The IF function is a great function. Let's take a look at a few more cool examples.

1. For example, use IF and AND to test if a value is between two numbers.

Explanation: the AND function returns TRUE if the person is older than 12 and younger than 20, else
it returns FALSE. If TRUE, the IF function returns Yes, if FALSE, the IF function returns No.

Formula: =IF(AND(B2>12,B2<20),"Yes","No")

2. You can combine IF with AVERAGE, SUM and other Excel functions. The sky is the limit!

Explanation: the AND function returns TRUE if the input value is greater than 100 and the average of
the values in the named range Data1 is greater than 100, else it returns FALSE. If TRUE, the IF function
returns the sum of Data2, if FALSE, the IF function returns 0.

Formula: =IF(AND(F3>100,AVERAGE(Data1)>100),SUM(Data2),0)

8
Fast Track Series - Microsoft Office Excel Advanced

2.0 Working with Lookups


2.1 The VLOOKUP function

The VLOOKUP function is one of the most popular functions in Excel. This page contains many easy to
follow VLOOKUP examples.

The VLOOKUP (Vertical lookup) function looks for a value in the leftmost column of a table, and then
returns a value in the same row from another column you specify.

1. Insert the VLOOKUP function shown below.

Explanation: the VLOOKUP function looks for the ID (104) in the leftmost column of the range
$E$4:$G$7 and returns the value in the same row from the third column (third argument is set to 3).
The fourth argument is set to FALSE to return an exact match or a #N/A error if not found.

Formula: =VLOOKUP(A2,$E$4:$G$7,3,FALSE)

9
Fast Track Series - Microsoft Office Excel Advanced

2. Drag the VLOOKUP function in cell B2 down to cell B11.

Note: when we drag the VLOOKUP function down, the absolute reference ($E$4:$G$7) stays the same,
while the relative reference (A2) changes to A3, A4, A5, etc.

Exact Match

Most of the time you are looking for an exact match when you use the VLOOKUP function in Excel.
Let's take a look at the arguments of the VLOOKUP function.

1. The VLOOKUP function below looks up the value 53 (first argument) in the leftmost column of the
red table (second argument).

Formula: =VLOOKUP(H2,B3:E9,4,FALSE)

10
Fast Track Series - Microsoft Office Excel Advanced

2. The value 4 (third argument) tells the VLOOKUP function to return the value in the same row from
the fourth column of the red table.

Note: the Boolean FALSE (fourth argument) tells the VLOOKUP function to return an exact match. If
the VLOOKUP function cannot find the value 53 in the first column, it will return a #N/A error.

3. Here's another example. Instead of returning the salary, the VLOOKUP function below returns the
last name (third argument is set to 3) of ID 79.

11
Fast Track Series - Microsoft Office Excel Advanced

Approximate Match

Let's take a look at an example of the VLOOKUP function in approximate match mode (fourth
argument set to TRUE).

1. The VLOOKUP function below looks up the value 85 (first argument) in the leftmost column of the
red table (second argument). There's just one problem. There's no value 85 in the first column.

2. Fortunately, the Boolean TRUE (fourth argument) tells the VLOOKUP function to return
an approximate match. If the VLOOKUP function cannot find the value 85 in the first
column, it will return the largest value smaller than 85. In this example, this will be the
value 80.

12
Fast Track Series - Microsoft Office Excel Advanced

3. The value 2 (third argument) tells the VLOOKUP function to return the value in the same row from
the second column of the red table.

Note: always sort the leftmost column of the red table in ascending order if you use the VLOOKUP
function in approximate match mode (fourth argument set to TRUE).

Formula: =VLOOKUP(F3,B3:C7,2,TRUE)

13
Fast Track Series - Microsoft Office Excel Advanced

2.2 The HLOOKUP function

In a similar way, you can use the HLOOKUP (Horizontal lookup) function.

14
Fast Track Series - Microsoft Office Excel Advanced

2.3 INDEX & MATCH

The INDEX function below returns a specific value in a two-dimensional range.

Explanation: 92 found at the intersection of row 3 and column 2 in the range E4:F7.

Formula: =INDEX(E4:F7,A2,B2)

The INDEX function below returns a specific value in a one-dimensional range.

Explanation: 97 found at position 3 in the range E4:E7.

Formula: =INDEX(E4:E7,A2)

15
Fast Track Series - Microsoft Office Excel Advanced

Explanation: the INDEX function returns the 5th value (second argument) in the range E3:E9 (first
argument).

Formula: =INDEX(E3:E9,5)

The MATCH function returns the position of a value in a given range.

The MATCH function returns the position of a value in a given range. For example, the MATCH function
below looks up the value 53 in the range B3:B9.

Formula: =MATCH(A2,E4:E7,0)

16
Fast Track Series - Microsoft Office Excel Advanced

Explanation: 53 (first argument) found at position 5 in the range B3:B9 (second argument). In this
example, we use the MATCH function to return an exact match so we set the third argument to 0.

Formula: =MATCH(H2,B3:B9,0)

17
Fast Track Series - Microsoft Office Excel Advanced

Instead of using VLOOKUP, use INDEX and MATCH. To perform advanced lookups, you'll need INDEX
and MATCH. Maybe this is one step too far for you at this stage, but it shows you one of the many
other powerful formulas Excel has to offer. Replace the value 5 in the INDEX function (see previous
example) with the MATCH function (see first example) to lookup the salary of ID 53.

Explanation: the MATCH function returns position 5. The INDEX function needs position 5. It's a perfect
combination. If you like, you can also use the VLOOKUP function. It's up to you. However, you'll need
INDEX and MATCH to perform advanced lookups, as we will see next.

Formula: =INDEX(B3:E9,MATCH(H2,B3:B9,0),4)

The INDEX function can also return a specific value in a two-dimensional range. For example, use
INDEX and MATCH in Excel to perform a two-way-lookup.

Formula: =INDEX(B2:D13,MATCH(G2,A2:A13,0),MATCH(G3,B1:D1,0))

18
Fast Track Series - Microsoft Office Excel Advanced

3.0 Data Validation


3.1 Using data validation

This example teaches you how to use data validation to prevent users from exceeding a budget limit.

1. Select the range B2:B8.

Note: cell B10 contains a SUM function that calculates the sum of the range B2:B8.

2. On the Data tab, in the Data Tools group, click Data Validation.

3. In the Allow list, click Custom.

19
Fast Track Series - Microsoft Office Excel Advanced

4. In the Formula box, enter the formula shown below and click OK.

Explanation: the sum of the range B2:B8 may not exceed the budget limit of $100. Therefore, we apply
data validation to the range B2:B8 (not cell B10!) because this is where the values are entered. Because
we selected the range B2:B8 before we clicked on Data Validation, Excel automatically copies the
formula to the other cells. Notice how we created an absolute reference ($B$2:$B$8) to fix this
reference.

5. To check this, select cell B3 and click Data Validation.

As you can see, this cell also contains the correct formula.

20
Fast Track Series - Microsoft Office Excel Advanced

6. Enter the value 30 into cell B7.

Result. Excel shows an error alert. You cannot exceed your budget limit of $100.

Note: to enter an error alert message, go to the Error Alert tab.

21
Fast Track Series - Microsoft Office Excel Advanced

3.2 Setting criteria for entry of text, values and dates

This example teaches you how to use data validation to reject invalid dates.

1. Select the range A2:A4.

2. On the Data tab, in the Data Tools group, click Data Validation.

A. Outside a Date Range

3. In the Allow list, click Date.

4. In the Data list, click between.

5. Enter the Start date and End date shown below and click OK.

Explanation: all dates between 5/20/2016 and today's date + 5 days are allowed. All dates outside this
date range are rejected.

22
Fast Track Series - Microsoft Office Excel Advanced

6. Enter the date 5/19/2016 into cell A2.

Result. Excel shows an error alert.

Note: to enter an input message and error alert message, go to the Input Message and
Error Alert tab.

B. Sundays and Saturdays

3. In the Allow list, click Custom.

4. In the Formula box, enter the formula shown below and click OK.

Explanation: the WEEKDAY function returns a number from 1 (Sunday) to 7 (Saturday)


representing the day of the week of a date. If a date's weekday is not equal to 1 (Sunday)
AND not equal to 7 (Saturday), the date is allowed (<> means not equal to). In other words,
Mondays, Tuesdays, Wednesdays, Thursdays and Fridays are allowed. Sundays and
Saturdays are rejected. Because we selected the range A2:A4 before we clicked on Data
Validation, Excel automatically copies the formula to the other cells.

23
Fast Track Series - Microsoft Office Excel Advanced

5. To check this, select cell A3 and click Data Validation.

As you can see, this cell also contains the correct formula.

6. Enter the date 8/27/2016 (Saturday) into cell A2.

Result. Excel shows an error alert.

Note: to enter an input message and error alert message, go to the Input Message and Error Alert tab.

24
Fast Track Series - Microsoft Office Excel Advanced

3.3 Creating a dropdown list

Drop-down lists in Excel are helpful if you want to be sure that users select an item from a list, instead
of typing their own values.

Create a Drop-down List

To create a drop-down list in Excel, execute the following steps.

1. On the second sheet, type the items you want to appear in the drop-down list.

Note: if you don't want users to access the items on Sheet2, you can hide Sheet2. To achieve this, right
click on the sheet tab of Sheet2 and click on Hide.

2. On the first sheet, select cell B1.

3. On the Data tab, in the Data Tools group, click Data Validation.

The 'Data Validation' dialog box appears.

4. In the Allow box, click List.

25
Fast Track Series - Microsoft Office Excel Advanced

5. Click in the Source box and select the range A1:A3 on Sheet2.

6. Click OK.

Result:

Note: to copy/paste a drop-down list, select the cell with the drop-down list and press CTRL + c, select
another cell and press CTRL + v.

26
Fast Track Series - Microsoft Office Excel Advanced

7. You can also type the items directly into the Source box, instead of using a range reference.

Note: this makes your drop-down list case sensitive. For example, if a user types yes, an error alert will
be displayed.

27
Fast Track Series - Microsoft Office Excel Advanced

4.0 PivotTables and PivotCharts


4.1 Creating and rearranging PivotTables

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.

28
Fast Track Series - Microsoft Office Excel Advanced

3. Click OK.

29
Fast Track Series - Microsoft Office Excel Advanced

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.

30
Fast Track Series - Microsoft Office Excel Advanced

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.

31
Fast Track Series - Microsoft Office Excel Advanced

Result.

32
Fast Track Series - Microsoft Office Excel Advanced

4.2 Using the PivotTable toolbar

You may have noticed the PivotTable Tools tabs that appear when you inserted your chart. These
contextual tabs are used throughout Office 2010. The appropriate tab appears, depending on which
type of object you are using.

Analyse

Design

33
Fast Track Series - Microsoft Office Excel Advanced

4.3 Creating PivotCharts

A pivot chart is the visual representation of a pivot table in Excel. Pivot charts and pivot tables are
connected with each other.

Insert Pivot Chart

To insert a pivot chart, execute the following steps.

1. Click any cell inside the pivot table.

2. On the Analyze tab, in the Tools group, click PivotChart.

The Insert Chart dialog box appears.

34
Fast Track Series - Microsoft Office Excel Advanced

3. Click OK.

Below you can find the pivot chart. This pivot chart will amaze and impress your boss.

Note: any changes you make to the pivot chart are immediately reflected in the pivot table and vice
versa.

35
Fast Track Series - Microsoft Office Excel Advanced

4.4 Using Slicers to manipulate PivotTables

Use slicers in Excel to quickly and easily filter pivot tables. Connect multiple slicers to multiple pivot
tables to create awesome reports.

To insert a slicer, execute the following steps.

1. Click any cell inside the pivot table.

2. On the Analyze tab, in the Filter group, click Insert Slicer.

3. Check Country and click OK.

36
Fast Track Series - Microsoft Office Excel Advanced

4. Click United States to find out which products we export the most to the United States.

Conclusion: bananas are our main export product to the United States. The report filter (cell B1)
changes to United States.

OK, that was pretty easy. Let's insert a second slicer.

5. Click any cell inside the pivot table.

6. On the Analyze tab, in the Filter group, click Insert Slicer.

7. Check Product and click OK.

8. Select the slicer.

37
Fast Track Series - Microsoft Office Excel Advanced

9. On the Options tab, in the Slicer Styles group, click a slicer style.

10. Use the second slicer. Click the Multi-Select button to select multiple products.

Note: instead of using the Multi-Select button, hold down CTRL to select multiple items.

To really impress your boss, execute the following steps.

11. Insert a second pivot table.

To connect both slicers to this pivot table, execute the following steps.

12. Select the first slicer.

38
Fast Track Series - Microsoft Office Excel Advanced

13. On the Options tab, in the Slicer group, click Report Connections.

14. Select the second pivot table and click OK.

15. Repeat steps 12-14 for the second slicer.

16. Use both slicers.

Conclusion: the total amount of apples exported to Canada equals $24,867 (6 orders) and the total
amount of oranges exported to Canada equals $19,929 (3 orders).

39
Fast Track Series - Microsoft Office Excel Advanced

17. Click the icon in the upper-right corner of a slicer to clear the filter.

Note: we didn't export any beans or carrots to Canada. Try it yourself, download the Excel file and use
slicers to create awesome reports.

40
Fast Track Series - Microsoft Office Excel Advanced

5.0 Using analytical options


5.1 Using Goal Seek

If you know the result you want from a formula, use Goal Seek in Excel to find the input value that
produces this formula result.

Goal Seek Example 1

Use Goal Seek in Excel to find the grade on the fourth exam that produces a final grade of 70.

1. The formula in cell B7 calculates the final grade.

2. The grade on the fourth exam in cell B5 is the input cell.

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

4. Click Goal Seek.

41
Fast Track Series - Microsoft Office Excel Advanced

The Goal Seek dialog box appears.

5. Select cell B7.

6. Click in the 'To value' box and type 70.

7. Click in the 'By changing cell' box and select cell B5.

8. Click OK.

Result. A grade of 90 on the fourth exam produces a final grade of 70.

42
Fast Track Series - Microsoft Office Excel Advanced

Goal Seek Example 2

Use Goal Seek in Excel to find the loan amount that produces a monthly payment of $1500.

1. The formula in cell B5 calculates the monthly payment.

Explanation: the PMT function calculates the payment for a loan. If you've never heard of this function
before, that's OK. The higher the loan amount, the higher the monthly payment. Assume, you can only
afford $1500 a month. What is your maximum loan amount?

2. The loan amount in cell B3 is the input cell.

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

4. Click Goal Seek.

The Goal Seek dialog box appears.

5. Select cell B5.

6. Click in the 'To value' box and type -1500 (negative, you are paying out money).

43
Fast Track Series - Microsoft Office Excel Advanced

7. Click in the 'By changing cell' box and select cell B3.

8. Click OK.

Result. A loan amount of $250,187 produces a monthly payment of $1500.

44
Fast Track Series - Microsoft Office Excel Advanced

5.2 Creating, saving and viewing scenarios

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.

45
Fast Track Series - Microsoft Office Excel Advanced

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.

46
Fast Track Series - Microsoft Office Excel Advanced

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.

47
Fast Track Series - Microsoft Office Excel Advanced

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.

48
Fast Track Series - Microsoft Office Excel Advanced

5.3 Creating single input data tables

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 below
calculates a total profit of 60 * $50 + 40 * $20 = $3800.

To create a one variable data table, execute the following steps.

1. Select cell B12 and type =D10 (refer to the total profit cell).

2. Type the different percentages in column A.

3. Select the range A12:B17.

We are going to calculate the total profit if you sell 60% for the highest price, 70% for the highest
price, etc.

49
Fast Track Series - Microsoft Office Excel Advanced

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

5. Click Data Table.

6. Click in the 'Column input cell' box (the percentages are in a column) and select cell C4.

We select cell C4 because the percentages refer to cell C4 (% sold for the highest price). Together with
the formula in cell B12, Excel now knows that it should replace cell C4 with 60% to calculate the total
profit, replace cell C4 with 70% to calculate the total profit, etc.

Note: this is a one variable data table so we leave the Row input cell blank.

7. Click OK.

50
Fast Track Series - Microsoft Office Excel Advanced

Result.

Conclusion: if you sell 60% for the highest price, you obtain a total profit of $3800, if you sell 70% for
the highest price, you obtain a total profit of $4100, etc.

Note: the formula bar indicates that the cells contain an array formula. Therefore, you cannot delete
a single result. To delete the results, select the range B13:B17 and press Delete.

51
Fast Track Series - Microsoft Office Excel Advanced

5.4 Creating double input data tables

To create a two variable data table, execute the following steps.

1. Select cell A12 and type =D10 (refer to the total profit cell).

2. Type the different unit profits (highest price) in row 12.

3. Type the different percentages in column A.

4. Select the range A12:D17.

We are going to calculate the total profit for the different combinations of 'unit profit (highest price)'
and '% sold for the highest price'.

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

52
Fast Track Series - Microsoft Office Excel Advanced

6. Click Data Table.

7. Click in the 'Row input cell' box (the unit profits are in a row) and select cell D7.

8. Click in the 'Column input cell' box (the percentages are in a column) and select cell C4.

We select cell D7 because the unit profits refer to cell D7. We select cell C4 because the percentages
refer to cell C4. Together with the formula in cell A12, Excel now knows that it should replace cell D7
with $50 and cell C4 with 60% to calculate the total profit, replace cell D7 with $50 and cell C4 with
70% to calculate the total profit, etc.

9. Click OK.

Result.

Conclusion: if you sell 60% for the highest price, at a unit profit of $50, you obtain a total profit of
$3800, if you sell 80% for the highest price, at a unit profit of $60, you obtain a total profit of $5200,
etc.

Note: the formula bar indicates that the cells contain an array formula. Therefore, you cannot delete
a single result. To delete the results, select the range B13:D17 and press Delete.

53
Fast Track Series - Microsoft Office Excel Advanced

6.0 Macros
6.1 Creating macros

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.

To turn on the Developer 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).

54
Fast Track Series - Microsoft Office Excel Advanced

3. Check the Developer check box.

4. Click OK.

5. You can find the Developer tab next to the View tab.

55
Fast Track Series - Microsoft Office Excel Advanced

6.2 Using the macro recorder

The Macro Recorder, a very useful tool included in Excel VBA, records every task you perform with
Excel. All you have to do is record a specific task once. Next, you can execute the task over and over
with the click of a button. The Macro Recorder is also a great help when you don't know how to
program a specific task in Excel VBA. Simply open the Visual Basic Editor after recording the task to
see how it can be programmed.

Unfortunately, there are a lot of things you cannot do with the Macro Recorder. For example, you
cannot loop through a range of data with the Macro Recorder. Moreover, the Macro Recorder uses a
lot more code than is required, which can slow your process down.

Record a Macro

1. On the Developer tab, click Record Macro.

2. Enter a name.

56
Fast Track Series - Microsoft Office Excel Advanced

3. Select This Workbook from the drop-down list. As a result, the macro will only be available in the
current workbook.

Note: if you store your macro in Personal Macro Workbook, the macro will be available to all your
workbooks (Excel files). This is possible because Excel stores your macro in a hidden workbook that
opens automatically when Excel starts. If you store your macro in New Workbook, the macro will only
be available in an automatically new opened workbook.

4. Click OK.

5. Right mouse click on the active cell (selected cell). Be sure not to select any other cell! Next, click
Format Cells.

57
Fast Track Series - Microsoft Office Excel Advanced

6. Select Percentage.

7. Click OK.

8. Finally, click Stop Recording.

Congratulations. You've just recorded a macro with the Macro Recorder!

58
Fast Track Series - Microsoft Office Excel Advanced

Run a Recorded Macro

Now we'll test the macro to see if it can change the number format to Percentage.

1. Enter some numbers between 0 and 1.

2. Select the numbers.

3. On the Developer tab, click Macros.

59
Fast Track Series - Microsoft Office Excel Advanced

4. Click Run.

Result:

60
Fast Track Series - Microsoft Office Excel Advanced

See the Macro

To take a look at the macro, open the Visual Basic Editor.

Note: the macro has been placed into a module called Module1. Code placed into a module is available
to the whole workbook. That means you change the number format of cells on other sheets as well.
Remember, code placed on a sheet (assigned to a command button) is only available for that particular
sheet.

Recording in Absolute Mode

To record a macro in absolute mode, execute the following steps.

1. First, click Record Macro.

2. Next, select cell B3. Type Sales and press enter.

3. Type Production and press enter.

4. Type Logistics and press enter.

61
Fast Track Series - Microsoft Office Excel Advanced

Result:

5. Click Stop Recording.

6. Empty Range("B3:B5").

7. Select any cell on the sheet and run the recorded macro.

Result:

A macro recorded in absolute mode always produces the same result.

62
Fast Track Series - Microsoft Office Excel Advanced

Recording in Relative Mode

Wouldn't it be nice to place these words anywhere on the sheet automatically? Not just
Range("B3:B5"). This would make the macro much more flexible. Solution: record the macro in relative
mode.

1. Select "Use Relative References".

2. First, select any single cell (for example, cell B8).

3. Next, click Record Macro.

4. Type Sales and press enter.

5. Type Production and press enter.

6. Type Logistics and press enter.

Result:

7. Click Stop Recording.

8. Select any other cell (for example, cell D4) and run the recorded macro.

63
Fast Track Series - Microsoft Office Excel Advanced

Result:

Excel places the words relative to the initial selected cell. That's why it's called recording in relative
mode.

64

You might also like