Sie sind auf Seite 1von 13

Advanced Excel Features

1. Excel Controls Use the Forms tool bar to create controls.


o o

Check Boxsets the value of a specified cell to True or False. Option Buttonselects one of a group of mutually-exclusive options. List Box1a box containing a list of items for the user to select. Scroll Bar2a control for changing the value of a cell incrementally or by page changes. Click the arrow causes incremental changes. Click around the scroll box causes page changes Spinner2a scroll bar with no page changes. In every case, the value of a specified (linked) cell reflects your choice.

2. Conditional formatting 3. Advanced worksheet functions


VLOOKUP IF SUMIF OFFSET

4. In-class exercises.

A Combo Box (a drop-down list of items for the user to select) is very similar to a List Box Covered in a later class 1

Excel Check Boxes


A Check Box is a control that sets the value of a specified cell to True or False. To define a new Check Box, select View, Toolbars, Forms. You will get the Forms toolbar, shown at the right:

Check Box Button

(The Control Toolbox menu also has Check Boxes, etc. but they are more VBA oriented.) Left click the Check Box button and then move the cursor to the worksheet. The cursor turns into a +. Hold the left mouse button down, drag the Check Box to the desired shape, and release the mouse button. Hubs around the Check Box, as shown at the left below, mean that it can be moved (hold the left mouse button and drag it), changed (left click the text and the cursor turns into an I within the hubs), or formatted (right click the Check Box). To format the Check Box, right click it and select Format Control. The Control Tab is the important setting. The example below shows that the Check Box is linked to cell A1 with initial value unchecked.

Example use of Check Box: When the user checks Yes, the value of cell A1 is changed to TRUE. If unchecked, the value is FALSE. You can use this to display optional results using formulas such as =IF(A1=TRUE,SUM(C1:C10),) (If A1 is not true, the cell display is blank.) 2

Excel Option Buttons


An Option Button is a control that can be used to select one of a group of mutually-exclusive options. To define a new Option Button, select View, Toolbars, Forms. You will get the Forms toolbar:

Option Button

Left click the Option Button and then move the cursor to the worksheet. The cursor turns into a +. Hold the left mouse button down, drag the Option Button to the desired shape, and release the mouse button. Hubs around the Option Box, as shown on the left below, mean that it can be moved (hold the left mouse button and drag it), changed (left click the text and the cursor turns into an I within the hubs), or formatted (right click the Option Box). To format the Option Box, right click it and select Format Control. The Control Tab is the important setting. The example below shows that the Option Box is linked to cell A1 with the initial value of checked.

Example use of Option Button: When user checks the option of staff, the value of cell A1 becomes 2. If the user selects faculty, A1 changes to 1. This can be used with the SUMIF function. 3

Excel List Boxes


A List Box is a control consisting of a box containing a list of items. To define a new List Box, select View, Toolbars, Forms. You will get the Forms toolbar:

List Box Button

Left click the List Box button and then move the cursor to the worksheet. The cursor turns into a +. Hold the left mouse button down, drag the List Box to the desired shape, and release the mouse button. Hubs around the List Box, as shown on the left below, mean that it can be moved (hold the left mouse button and drag it), or formatted (right click it). To format the List Box, right click it and select Format Control. The Control Tab is the important setting. The example below shows that: the input range, which refers to a list of values in a worksheet, is $C$6:$C$9, and the cell link is $A$1. This returns a value that represents the selected item in the list. Check Single in the selection type to specify how items are to be selected in the list. (Multi and Extend are used only for VBA and should have been grayed out.)

This is the input range (normally hidden in another worksheet or screen.)

Example use of List Box: When the user checks the option of student within the list box, the value of cell A1 becomes 3. This can be used in a SUMIF function. 4

Excel Combo Boxes


A Combo Box is a control containing a text box with a drop-down list box. To define a new Combo Box, select View, Toolbars, Forms. You will get the Forms toolbar:

Combo Box Button

Left click the Combo Box button and then move the cursor to the worksheet. The cursor turns into a +. Hold the left mouse button down, drag the Combo Box to the desired shape, and release the mouse button. Hubs around the Combo Box, as shown the left below, mean that it can be moved (hold the left mouse button and drag it), or formatted (right click the Combo Box). To format the Combo Box, right click it and select Format Control. The Control Tab is the important setting. The example below shows: the input range, which refers to a list of values in a worksheet, is $C$6:$C$9, and the cell link is $A$1. This returns a value that represents the selected item in the list. Input the number in the box of drop down lines to specify the number of lines to display in the drop-down list.

This is the input range (normally hidden in another worksheet or screen.)

Example use of Combo Box: When the user checks the option of faculty from the pull-down list, the value of cell A1 becomes 1. 5

Custom Scroll Bars, Spinners, and Conditional Formatting Scroll barIcon linked to a cell:

Click the arrow causes incremental changes Click around the scroll box causes page changes

SpinnerScroll Bar with no page changes. Using the Forms tool bar to create scroll bars and spinners. Conditional formatting:

OFFSET function SUMPRODUCT function

Excel Scroll Bars


Select View, Toolbars, Forms: You will get the Forms toolbar:

Scroll Bar Button

A Spinner is a Scroll Bar with No Page Changes

Left-click the Scroll Bar button and move the cursor to the work sheet. The cursor turns into a +. Hold the left mouse button down, drag the scroll bar to the desired shape, and release the mouse button. Hubs around the scroll bar, as shown on the left below, mean that it can be moved (hold the left mouse button and drag it) or formatted (right click it). Right click the custom scroll bar and select Format Control. The Control Tab is the important setting. The example below shows that the scroll bar is linked to cell A1 with values between 5 and 50. Hitting the scroll arrow increases A1 by 5 (Incremental change). Hitting Page change increments A1 by 10.

Page change

Incremental change

Conditional Formatting
Conditional formatting is the formatting of a range that appears only when conditions that you specify are met. It is typically used to highlight cells of particular interest or that contain unusual values, such as negative numbers. Example 1Conditionally format a cell to have green patterns when its value equals 5.

First select the cell and then select the Format menu and conditional formatting:

This gives the dialog box at the right. Note that there is a choice of Cell Value Is or Formula Is. Choose Cell Value Is, select Equal To and enter 5 in the first three areas, respectively. Next, click the Format. button, select the Patterns tab, and choose the green color. Select OK which returns you to the dialog box above. Select OK.

Example 2Conditionally format a range to have red patterns for each cell whose value equals that given by another cell. Highlight the entire range and select the options shown at the right. Note that the entire range is conditionally formatted at the same time. Whenever the condition is true, the corresponding cell has red patterns. Example 3Conditionally format a range to show the minimum value with green shading and the maximum value with red shading. Highlight the entire range with the upper left cell active. Conditionally format and choose Formula Is. Enter the formula shown in the dialog box below; note that A1 is a relative cell reference, and $A$1:$E$3 is an absolute cell reference. Because the entire range is selected, the conditional formatting applies to every cell in the range. Thus each cell will have green patterns if it is the minimum of $A$1:$E$3. The formula adjusts for other cells such as B1, B2, etc. However, the $A$1:$E$3 does not adjust for these other cells. This single formula is equivalent to separately selecting and conditionally formatting each individual cell in this range. For example, we could select only C2 and use conditional formatting with the formula =IF(C2=MIN($A$1:$E$3), TRUE, FALSE)3, and green patterns are used when the formula is true. After entering the above formula, select the Format. button and choose a green pattern as before. Next, select Add >> and use the formula IF(A1=MAX $A$1:$E$3), TRUE, FALSE). Format the cells red as before.

The simpler form =C2=MIN($A$1:$E$3) can be used instead of IF(C2=MIN($A$1:$E$3), TRUE, FALSE)
3

Conditionally Formatting a Range Defined by Another Cells Value


First set up a custom scroll bar linked to cell B30:

Then format B6:I7 and B9:I12 with red patterns only when B$6 = $B$30

10

The rest of this document is optional advanced reading (not testable) Active X Controls (Optional Advanced Section) Excel has additional Active X Controls (which include advanced versions of the Form controls discussed above) in the Control Toolbox toolbar. The Control Toolbox toolbar and the Form toolbar look so similar, as shown at the right, that users often confuse the two. Most Active X controls are intended for use with macros, so they should be used only when Form controls dont suffice. One useful Active X control is the Calendar Control. To add this control, view the Control Toolbox toolbar and select the wrench and hammer icon, which is circled in the figure. When the dialog box appears, scroll through the alphabetical list to the Calendar Control 11.0 item. Click anywhere in the sheet and a calendar item will appear4. You may then resize or move the calendar. After placing any Active X control, the user must program it. With the calendar control selected, click the Properties button5 at the upper right of the Control Toolbox toolbar. In the pop up Properties window that appears, type a cell reference for the Linked Cell property (you cant use the mouse to identify the cell). The figure shows H5 set as the linked cell. Close the Properties window by clicking the X in its upper right hand corner, and then click the Design Mode button at the upper left to exit Design Mode and activate the calendar. Now by pressing a date on the calendar control, that date appears in the linked cell. Note that the value returned by the control is text, not a date value. This is a subtle but important difference that must be addressed if numerical use is needed such as with the X (horizontal) axis of a chart. The easiest way to convert the date text value to a true date value is to use the DATEVALUE worksheet function in another cell. For example, placing =DATEVALUE(H5) in cell J5 will allow you to compare this value with other dates. J5 needs to be formatted as a date for it to display correctly.

Change the month and year using these drop down arrows

Alternatively, the calendar control can be placed like form controls by left clicking and dragging. You must be in design mode. If you are not already, click the top left button of the control toolbox toolbar to toggle on design mode. When first placing a calendar, you are automatically placed in design mode.
4 5

11

Limits of scroll bars and spinners (Optional Advanced Section) Scroll bars cannot directly produce negative values, decimals, values greater than 30,000, or text values. However, these values can be produced indirectly. For example, to make a scroll bar range from 0.05 to 0.10, link the scroll bar directly to a cell such as A1 with values between 5 and 10. In another cell such as A2 insert the formula =A1/100. When the user changes A1 from 5 to 6 with the scroll bar, A2 changes from 0.05 to 0.06. To make a scroll bars range from -50 to 50 (which is a range of 100), link the scroll bar to A1 with a minimum value of 0 and a maximum value of 100. Insert =A1 - 50 in another cell. When the user changes A1 from 1 to 2 with the scroll bar, the other cell changes from -49 to -48. To get values greater than 30,000, the user can either add or multiply the cell directly linked to the scroll bar. Finally, an OFFSET can be used to reference other cells containing text. For example, a scroll bar can be linked to A1 with values between 1 and 5. The user changes A1 with the scroll bar, and another cell contains =OFFSET(B1,0,A1), which offsets from B1 by no rows and a number of columns equal to the value in A1. This returns the value in C1, D1, E1, F1, or G1, which contain the desired text. Control Positions (Optional Advanced Section) All form and Active X controls have move and size properties that can be changed. In the example at the left below there are two check boxes side by side. If columns C:E are deleted, the two controls then overlap, as shown in the figure at the right below.

To prevent this, right click each control and select Format Control and the Properties tab. Now select Dont move or size with cells, as shown in the figure below, and then click OK. Now if columns C:E are deleted, the two controls remain in their original positions, as shown in the figure at the right below. Use this option when you want controls to remain stationary regardless of how the surrounding columns or rows are re-sized or deleted are manipulated.

12

Using VLOOKUP with Combo and ListBox Controls (Optional Advanced Section) Combo and ListBox form controls return an integer value to the linked cell, not the text value selected. The example below shows a combo box with three choicesstudents, staff, or faculty. The user selected Staff from the combo box. Since Staff is the second entry in that list, the combo box returns the number 2 to its linked cell ($E$9). Whenever a selection is made from the combo box, we want another cell to display the parking lot assigned to that group. The formula =VLOOKUP(E9,A3:C5,2,0) produces the desired result. Alternatively, =OFFSET(C2,E9,0) could be used.

13

Das könnte Ihnen auch gefallen