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

540

POWER EXCEL WITH MR EXCEL

 

 

 

USE VALIDATION TO PREVENT DUPLICATE DATA ENTRY

Problem: I want to prevent people from entering the same receipt number twice.

Strategy: Use the Custom form of Data Validation to prevent duplicate data entry.

Figure 1403 1234 has already been entered and is invalid.

It takes a bit of planning to make this work. In the example, the first receipt number is entered in A2. You want to prevent duplicates in A3:A100. You have to craft a formula that works for A3 but has the correct dollar signs so it can be applied to A4 through A100.

=COUNTIF(A$2:A2 uses an expanding range. When evaluated from the point of view of A3, this reference is saying to look at everything from row $2 to the row just above the current row. Copy the reference down and it will be looking at =COUNTIF(A$2:A99 when evaluated in A100.

You want to see how many times A3 was entered in A$2:A2. If this value is a duplicate, the COUNTIF would return a number larger than zero. Thus, the test to see if the new entry in A3 is not a duplicate would be =COUNTIF(A$2:A2,A3)=0.

Follow these steps: 1. Select A3:A100

2. Choose Data, Validation or press Alt+D, L

3. In the Allow dropdown, choose Custom

4. In the Formula box, type =COUNTIF(A$2:A2,A3)=0

5. On the Error Alert tab, use a Title of Duplicate Value and an Error Message of This Value Already Appears Above.

6. Click OK.

Figure 1404 Prevent duplicate entries with this formula

USE VALIDATION TO CREATE DEPENDENT LISTS

Problem: I want to create two dropdown lists. The second list should be dependent on what is selected in the first one.

Strategy: You can use the INDIRECT function as the source of the second list. Follow these steps:

PART 4: MAKING THINGS LOOK GOOD

541

 

 

1.On a blank sheet, set up a list of items for the first dropdown: Writing, Science, Math, and Geogra- phy. Name the range Subjects.

2.In other columns, set up a list of choices available for each subject.

3.Name the second list Writing. It is critical that the range name for this list match the value in the original list.

4.Repeat step 3 for each item in the first list. In each case, the name of the new range must match the value in column A.

Figure 1405 Set up dependent lists, each with a name from the first list.

5. To select the subject from cell D2, select cell D2 and then select Data, Data Validation. Change the

Allow box to List; in the Source box, type =Subjects. 6. Click OK. Cell D2 will have a dropdown list of subjects.

7. To set up the second dropdown, select cell D4 and then select Data, Data Validation. Change the Allow dropdown under Validation Criteria from Any Value to List. In the Source box, enter =INDIRECT(D2).

Results: When you select a value in D2, the formula for the second dropdown list will automatically up- date. The INDIRECT function looks in D2 and hopes to find a formula there. When you select Writing in D2, the validation formula becomes =Writing. Because you cleverly set up a named range called Writing,

Excel is able to populate the list.

4

Figure 1406 Choose Science in D2, and the list in D4 reflects the Science list.

When you change D2 to Math, =INDIRECT(D2) will become =Math. Again, because you have a named range called Math, Excel is able to fill in the second dropdown with geography subjects.

Figure 1407 Change D2 to Geography and the validation list changes.

542

 

POWER EXCEL WITH MR EXCEL

 

 

 

ADD A TOOLTIP TO A CELL TO GUIDE THE PERSON USING THE WORKBOOK

Problem: Excel offers all sorts of ToolTips to help understand the ribbon icons. It would be cool if I could add a ToolTip to a cell.

Strategy: You can easily add an informative ToolTip to any cell. The ToolTip will appear when someone selects the cell. Follow these steps:

1. Move the cell pointer to the cell. From the ribbon, choose Data, Data Validation. In the Data Validation dialog, select the Input Message tab.

2. On the Input Message tab, type a title for the ToolTip. In the Input Message area, type instructions for the person filling out the worksheet.

Figure 1408 ToolTips provide instant help.

Figure 1409 Write the cell ToolTip on the Input Message tab.

Results: When you move the cell pointer to that cell, an informative ToolTip will appear.

Figure 1410 Help appears for an input cell.

Additional Details: This is an innovative use for the Validation command. You are not actually specify- ing anything in particular in Allow dropdown, but merely using one of the auxiliary settings in order to have the tool tip display. The validation input message only appears when the cell is selected and might be slightly preferable to cell comments since they will not litter the spreadsheet with tiny red triangles. For information on cell comments, see "Leave Helpful Notes with Cell Comments" on page 507.

COMBINE VALIDATION WITH AUTOCOMPLETE

Problem: The Validation dropdown is horrible for keyboard people. You can’t quickly jump to an item in the dropdown.

PART 4: MAKING THINGS LOOK GOOD

 

543

 

 

 

Strategy: Combine AutoComplete with Validation.

 

 

Several viewers of the Learn Excel from MrExcel

 

 

podcast sent in this idea when I complained about

 

 

the lack of keyboard support for validation. Thus,

 

 

I am guessing that the trick must be fairly wide-

 

 

spread.

 

 

Say that you want to enter products in column D.

 

 

Insert several rows above the D1 heading and store

 

 

the list above the heading. Set up the validation

 

 

below the heading.

 

 

When someone who is a mouse person comes along,

 

 

they will open the dropdown and use the mouse as

 

 

usual.

 

 

If someone who is a keyboard person comes along,

 

 

they can start typing the entry. The AutoComplete

 

 

will offer an item from the list above the heading.

Figure 1411 Validation works with the mouse.

 

Figure 1412 AutoComplete works for keyboard people.

 

AFTERWORD

 

There you have it: 617 problems and their solutions. Hopefully, you have found many that will make your

 

 

4

experience with Excel far more efficient. When I am teaching Power Excel class, every new class brings

 

new people with new problems, and you will undoubtedly run into problems that are not in this book. I

 

 

invite you to send your problems to pub@MrExcel.com. I’ll try to get an answer to you, and your question

 

might end up in the next edition of this book!

 

Any time I am in a room full of 100 accountants for a morning, I learn a few new tips. Do you know of a cool

 

technique that is not in the book? Send your tips to pub@MrExcel.com. If your tip is one I haven’t heard be-

 

fore, I will reward you with one of my Excel Master pins that you can wear to show off your Excel mastery.