Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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 3: WRANGLING DATA

277

 

 

Gotcha: Note that Excel added up the invoice numbers in column J. This makes no sense. 2. Delete column J.

3. The Consolidate command is not smart enough to take the first or last instance of text fields, so fill in the customer name, using a VLOOKUP function.

Figure 710 Use a VLOOKUP to fill text fields.

4. Copy the VLOOKUP function down by double-clicking the fill handle. Change the VLOOKUP for- mula to values by copying I2:I16 and then using Home, Paste dropdown, Paste Values.

5. Excel does not fill in the label in the upper-left corner of the table, so enter Acct in H1. The resulting data set is in the same sequence as the customers in the original list.

6. Choose a single cell in column I and click the AZ sort button to produce an alphabetical list by cus- tomer.

7. Because the column widths are not automatically adjusted as the result of a consolidation, use

Home, Format, AutoFit Column Width to adjust the column widths.

3

Figure 711 Duplicates removed and summarized.

REMOVE DUPLICATES

Problem: I have a data set in which I would like to find every unique combination of customer and prod- uct.

Figure 712 Find unique combinations of customer and product.

Strategy: Although there are several ways to find unique values (advanced filters, pivot tables, Microsoft Query, COUNTIF), Microsoft added a new feature to Excel 2007 called Remove Duplicates.

Remove Duplicates is a powerful feature—sometimes too powerful because it very quickly and destructively removes the duplicated rows.

To use the Remove Duplicates command, follow these steps:

278

POWER EXCEL WITH MR EXCEL

 

 

1.Make a copy of your data. Copy it to a new range, a new worksheet, or a new workbook.

2.Select one cell in your data set.

3.Select Data, Remove Duplicates. Excel will display the Remove Duplicates dialog.

4.Click Unselect All. Select Product and Customer.

Figure 713 Choose which columns should be analyzed.

5. Click OK. Excel will confirm how many duplicates were found and removed.

Figure 714 Duplicates removed.

Results: Excel will delete hundreds of rows of data! If you didn’t make a copy in step 1 and you need that data, press Ctrl+Z to undo.

PREVIEW REMOVE DUPLICATES WITHOUT REMOVING THEM

Problem: I want to preview which rows will be deleted before deleting them with Remove Duplicates.

Strategy: Use the Formula version of conditional formatting to highlight the cells that will be deleted.

Continuing the previous example, say that you want to remove all duplicates of Product+Customer.

Follow these steps: 1. Select A2:H564

2. Home, Conditional Formatting, New Rule, Use a Formula to Determine Which Cells to Format

3. In the Formula box, type =COUNTIFS($B$1:$B1,$B2,$D$1:$D1,$D2)>0. Note the four references with only a single dollar sign. Those missing dollar signs create an expanding range.

4. Click the Format... button.

5. Choose a Fill color. Click OK once for each open dialog box.

PART 3: WRANGLING DATA

279

 

 

Figure 715 The key to this formula are the eight dollar signs.

Excel will highlight which rows would be deleted by Remove Duplicates.

3

Figure 716 Anything highlighted is a duplicate of Product/Customer.

280

POWER EXCEL WITH MR EXCEL

 

 

 

PROTECT CELLS THAT CONTAIN FORMULAS

Problem: I have to key in data in a large number of cells in a month-end financial statement. I don’t want to accidentally key in a number in a cell that contains a formula. How can I protect just the formula cells?

Figure 717 Allow people to enter details but protect the formulas.

Strategy: After unlocking all cells, you can use the Go To Special dialog to select only the cells with for- mulas and lock just those cells.

By default, all cells in a worksheet start with their Locked property set to TRUE, but you may not realize this until you turn on protection for the first time. The first step is to unlock all the cells:

1. Select all cells by pressing Ctrl+A. Use Ctrl+One to open Format Cells.

2. Click on the Protection tab in the Format Cells dialog. You will see that the Locked option is chosen.

Figure 718 All cells start out locked by default.

3. Uncheck the Locked box. Click OK to close the Format Cells dialog. 4. Select Home, Find & Select, Formulas.

5. Excel will select all formulas on the current worksheet.

6. Select Home, Format dropdown, Lock Cells. This will lock only the selected cells, which are the for- mula cells.

7. Enable protection for the sheet. (Note that if you skip this final step, you can still accidentally over- write your formulas.) Select Home, Format dropdown, Protect Sheet.

Figure 719 Turn on Protection to use the Locked/Unlocked settings.

8. Excel will display the Protect Sheet dialog. The default settings are sufficient protection. Simply click OK.