Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Power excel 2016 with mrexcel Master Pivot Tables, Subtotals, Charts, VLOOKUP, IF, Data Analysis in Excel 2010–2013 (Bill Jelen) (z-lib.org).pdf
Скачиваний:
4
Добавлен:
14.08.2022
Размер:
49.75 Mб
Скачать

PART 2: CALCULATING WITH EXCEL

75

 

 

If you press Ctrl+Shift+U or click the down arrow icon at the right edge of the formula bar, Excel will shift the grid down and show more lines of the formula.

Figure 161 Excel lowers the grid.

Gotcha: With a particularly long formula, the formula might not fit in the expanded formula bar. Grab the bar at the bottom edge of the formula bar to make the formula bar even taller.

COPY A FORMULA THAT CONTAINS RELATIVE REFERENCES

 

 

2

Problem: I have 5,000 rows of data. After entering a formula to calculate gross profit percent for the first

row, how do I copy the formula down to other rows?

 

 

Figure 162 Copy a formula down to all rows.

Strategy: All of the cell references in the figure above are known as relative references. The amazing thing about Excel is that when you copy a formula, all of the relative cell references are automatically adjusted. If you copy a formula from row 2 down to row 3, as shown below, then every relative reference pointing at row 2 will change to point to row 3.

Figure 163 E2 changes to E3. F2 changes to F3.

So, the solution to the problem is simply to copy the formula down to all the other rows. A shortcut for do- ing this is to select the cell and then double-click the fill handle to copy the formula down to all rows with values in the adjacent column. The fill handle is the square dot in the lower right corner of the selection rectangle.

Additional Details: Relative references will move in all four directions. In the figure below, if you copy the formula in cell E5 to D4, the referenced cell will change from D3 to C2 (up one cell, and one cell to the left).

Figure 167 Copying the formula up will point to an invalid cell.

76

POWER EXCEL WITH MR EXCEL

 

 

Figure 164 Copy this formula up and to the left.

Figure 165 The original D3 reference changes as the formula is copied.

In the figure above, you can see how the formula copied to nine other cells will change.

Additional Details: The figures above were shot in Show Formulas mode. To enter Show Formulas mode, press Ctrl+`. (On a U.S. keyboard the grave accent is on the same key as the tilde, ~, just below the Esc key.) To toggle back to regular mode, press Ctrl+` again.

Gotcha: It is possible to copy a formula so that it will point to a cell that does not exist. The formula in the figure below is pointing at cell A1. If you copy that formula up one row, it would need to point to row zero. Since row zero does not exist, it becomes a #REF! error.

Figure 166 This formula already points to the top row.

The reference to A1 would have to point to the cell one row above and one column to the left of A1. That cell does not exist, so Excel will return a #REF error.

COPY A FORMULA WHILE KEEPING ONE REFERENCE FIXED

Problem: I have 5,000 rows of data. Each row contains a quantity and the unit price. The sales tax rate for all orders is shown in cell C1. After I enter a formula to calculate the total with sales tax in the first row, how do I copy the formula down to other rows?

Figure 168 This formula works in row 4…

PART 2: CALCULATING WITH EXCEL

77

 

 

If I copy the formula in F4 to F5, I get an invalid result of zero.

Look at the formula in the formula bar. As I copy the formula, the references to D4 and E4 changed as expected. However, the reference to C1 moved to C2. I need to find a way to copy this formula and always have the formula reference C1.

Note: This may be the most important technique in the entire book. I once had a manager who entered every formula in every data set by hand. I didn’t have the heart to tell him there was an easier way

Strategy: YouneedtoindicatetoExcelthattheref- erence to C1 in the formula is absolute. You do this by inserting a dollar sign before the C and before the 1 in the formula. For example, you would change the formula in F4 to =ROUND((D4*E4)*$C$1,2).

As you copy this formula down to other rows in your data set, the portion that refers to $C$1 will continue to point at $C$1, as shown below..

Figure 169 ...but the formula fails in other rows.

Figure 170 The dollar signs keep C1 pointing to C1.

2

Additional Details: See “Create a Multiplication Table” below to learn the effect of using just one dollar sign in a reference instead of two. Read "Simplify the Entry of Dollar Signs in Formulas" on page 79 to learn a cool shortcut for entering the dollar signs automatically.

CREATE A MULTIPLICATION TABLE

Problem: I want to create a multiplication table to help my kids in school. I want to be able to enter a single formula in cell B2 that I can copy to the entire table.

Figure 171 Need a formula to point to row 1 and column 1.

Strategy: In “Copy a Formula While Keeping One Reference Fixed,” you learned how to use an absolute reference, such as $C$1, so that Excel would not change from column C or row 1 as it copied the formula. To create a multiplication table, you need to use a mixed reference. A mixed reference, such as $A2, will lock the formula to column A while allowing the row to change. A mixed reference, such as B$1, will lock the row to row 1 while allowing the column to change.

The formula you need for the multiplication table is a formula that will multiply whatever is in row 1 above the cell by whatever is in column A to the left of the cell.

To have a reference that always points to row 1, you use something in the format of B$1. To have a reference that points to column A, you use a reference in the format of $A2.

1. Enter the formula =$A2*B$1 in B2.

78

POWER EXCEL WITH MR EXCEL

 

 

Figure 172 Multiply column A by row 1.

2. Copy the formula in B2 to the entire range.

Result: Excel will always properly multiply column A by row 1.

Figure 173 =$A13*M$1 creates the multiplication table.

CALCULATE A SALES COMMISSION

Problem: The VP of sales in my company has dreamt up the most convoluted sales plan in the history of the world. Rather than just paying the reps a straight commission, this plan involves paying a base rate and a 2% bonus based on the product sold, and a monthly profit sharing bonus. For the spreadsheet below,

I need to create a formula that can be copied to all rows and all months.

Figure 174 Perhaps the VP of sales designed the commission plan to test your knowledge of Excel!

Strategy: This formula will contain all four reference types: relative, mixed, the other mixed, and abso- lute. While entering the first formula in H6, you want to base the commission calculation on the January sales in E6. As you copy the formula from January to February, you want the E6 reference to be able to change to F6. As you copy the formula down to other rows, you want the E6 to change to E7, E8, and so on. Thus, the E6 portion of the formula needs to be a relative reference and will have no dollar signs.

You multiply the sales by the base rate in B1. As you copy the formula to other months and rows, it always needs to point to B1. Thus, you need to use dollar signs before the B and before the 1: $B$1.

To incorporate the product bonus, you need to multiply sales by the product rate in column C. All the months in row 6 have to refer to C6. All the months in row 7 have to refer to C7. Thus, you need a mixed reference where column C is locked; use the address of $C6.

Finally, to address the monthly profit sharing bonus, the entire commission calculation is multiplied by the bonus factor shown in row 1. The January commission calculation uses the factor in E1. The February