Sunteți pe pagina 1din 62

1 Overview of forms, form controls, and

ActiveX controls on a worksheet in Excel


2016 for Windows
Applies To: Excel 2013

By using forms and the many controls and objects that


you can add to them, you can make data entry on your worksheets easier and
improve the way your worksheets look. And you can do this yourself with little or
no need for Microsoft Visual Basic for Applications (VBA) code.
A worksheet form is not the same thing as an Excel template. A template is a pre-
formatted file that can get you started creating a workbook that looks the way
you want. A form contains controls, such as boxes or dropdown lists, that can
make it easier for people who use your worksheet to enter or edit data. To find
out more about templates you can download, see Excel templates.

1.1 In this article


What is a form?
Types of Excel forms

Data form
Worksheet with form and ActiveX controls
Form controls
ActiveX controls
Drawing tools objects
Working with controls and objects on a worksheet
Determining the type of control on a worksheet
VBA UserForms

1.2 What is a form?


Worksheet forms contain controls. Examples of common controls include list
boxes, option buttons, and command buttons. Controls can also run assigned
macros and respond to events, such as mouse clicks, by running Visual Basic for
Applications (VBA) code.
You can use Excel in several ways to create forms.
Top of Page

1.3 Types of Excel forms


There are several types of forms that you can create in Excel: data forms,
worksheets that contain Form and ActiveX controls, and VBA UserForms. You can
use each type of form by itself, or you can combine them in different ways to
create a solution that's right for you.
1.3.1 Data form
A data form provides a convenient way to enter or display one complete row of
information in a range or table without scrolling horizontally. You may find that
using a data form can make data entry easier than moving from column to
column when you have more columns of data than can be viewed on the screen.
Use a data form when a simple form of text boxes that list the column headings
as labels is sufficient and you don't need sophisticated or custom form features,
such as a list box or spin button.

Excel can automatically generate a built-in data form for your range or table. The
data form displays all column headers as labels in a single dialog box. Each label
has an adjacent blank text box in which you can enter data for each column, up
to a maximum of 32 columns. In a data form, you can enter new rows, find rows
by navigating, or (based on cell contents) update rows and delete rows. If a cell
contains a formula, the formula result is displayed in the data form, but you
cannot change the formula by using the data form.
Top of Page
1.3.2 Worksheet with Form and ActiveX controls
For added flexibility, you can add controls and other drawing objects to the
drawing canvas of a worksheet, and combine and coordinate them with
worksheet cells. For example, you can use a list box control to make it easier for
a user to select from a list of items. Or, you can use a spin button control to make
it easier for a user to enter a number.
Because controls and objects are stored on the drawing canvas, you can display
or view controls and objects alongside associated text that is independent of row
and column boundaries without changing the layout of a grid or table of data on
your worksheet. Most of the time, many of these controls can also be linked to
cells on the worksheet and do not require VBA code to make them work. You can
set properties that determine whether a control floats freely or moves and resizes
together with a cell. For example, you might have a check box that you want to
move together with its underlying cell when the range is sorted. However, if you
have a list box that you want to keep in a specific location at all times, you
probably do not want it to move together with its underlying cell.
Excel has two types of controls: Form controls and ActiveX Controls. In addition to
these sets of controls, you can also add objects from the Drawing tools, such as
AutoShapes, WordArt, SmartArt graphic, or text boxes.
The following sections describe these controls and drawing objects, and also
explain how to work with these controls and objects in more detail.
Top of Page
1.3.2.1 Form controls
Form controls are the original controls that are compatible with earlier versions of
Excel, starting with Excel version 5.0. Form controls are also designed for use on
XLM macro sheets.
You use Form controls when you want to easily reference and interact with cell
data without using VBA code, and when you want to add controls to chart sheets.
For example, after you add a list box control to a worksheet and link it to a cell,
you can return a numeric value for the current position of the selected item in the
control. You can then use that numeric value in conjunction with
the INDEX function to select different items from the list.
You can also run macros by using Form controls. You can attach an existing macro
to a control, or write or record a new macro. When a user of the form clicks the
control, the control runs the macro.
However, these controls cannot be added to UserForms, used to control events,
or modified to run scripts on web pages.
1.3.2.1.1 Summary of form controls
Butto Exampl Description
n e
Name

Label Identifies the purpose of a cell or text box,


or displays descriptive text (such as titles,
captions, pictures) or brief instructions.

Group Groups related controls into one visual unit


box in a rectangle with an optional label.
Typically, option buttons, check boxes, or
closely related contents are grouped.

Button Runs a macro that performs an action when


a user clicks it. A button is also referred to
as a push button.

Check Turns on or off a value that indicates an


box opposite and unambiguous choice. You can
select more than one check box on a
worksheet or in a group box. A check box
can have one of three states: selected
(turned on), cleared (turned off), and
mixed, meaning a combination of on and
off states (as in a multiple selection).

Option Allows a single choice within a limited set


button of mutually exclusive choices; an option
button is usually contained in a group box
or a frame. An option button can have one
of three states: selected (turned on),
cleared (turned off), and mixed, meaning a
combination of on and off states (as in a
multiple selection). An option button is also
referred to as a radio button.
Butto Exampl Description
n e
Name

List Displays a list of one or more items of text


box from which a user can choose. Use a list
box for displaying large numbers of choices
that vary in number or content. There are
three types of list boxes:
A single-selection list box enables only one
choice. In this case, a list box resembles a
group of option buttons, except that a list
box can show a large number of items in
less space.
A multiple-selection list box enables either
one choice or contiguous (adjacent)
choices.
An extended-selection list box enables one
choice, contiguous choices, and
noncontiguous (or disjointed) choices.

Combo Combines a text box with a list box to


box create a drop-down list box. A combo box is
more compact than a list box but requires
the user to click the down arrow to display
the list of items. Use a combo box to
enable a user to either type an entry or
choose only one item from the list. The
control displays the current value in the
text box, regardless of how that value is
entered.

Scroll Scrolls through a range of values when you


bar click the scroll arrows or drag the scroll
box. In addition, you can move through a
page (a preset interval) of values by
clicking the area between the scroll box
and either of the scroll arrows. Typically, a
user can also type a text value directly into
an associated cell or text box.
Butto Exampl Description
n e
Name

Spin Increases or decreases a value, such as a


button number increment, time, or date. To
increase the value, click the up arrow; to
decrease the value, click the down arrow.
Typically, a user can also type a text value
directly into an associated cell or text box.

Top of Page
1.3.2.2 ActiveX controls
ActiveX controls can be used on worksheet forms, with or without the use of VBA
code, and on VBA UserForms. In general, use ActiveX controls when you need
more flexible design requirements than those provided by Form controls. ActiveX
controls have extensive properties that you can use to customize their
appearance, behavior, fonts, and other characteristics.
You can also control different events that occur when an ActiveX control is
interacted with. For example, you can perform different actions, depending on
which choice a user selects from a list box control, or you can query a database
to refill a combo box with items when a user clicks a button. You can also write
macros that respond to events associated with ActiveX controls. When a user of
the form interacts with the control, your VBA code then runs to process any
events that occur for that control.
Your computer also contains many ActiveX controls that were installed by Excel
and other programs, such as Calendar Control 12.0 and Windows Media Player.
Not all ActiveX controls can be used directly on worksheets; some can be used
only on Visual Basic for Applications (VBA) UserForms. If you try to add any one of
these particular ActiveX controls to a worksheet, Excel displays the message
"Cannot insert object."
However, ActiveX controls cannot be added to chart sheets from the user
interface or to XLM macro sheets. You also can't assign a macro to run directly
from an ActiveX control the same way you can from a Form control.
1.3.2.2.1 Summary of ActiveX controls
Butto Example Description
n
Name

Check Turns on or off a value that indicates an


box opposite and unambiguous choice. You
can select more than one check box at a
time on a worksheet or in a group box. A
check box can have one of three states:
selected (turned on), cleared (turned off),
and mixed, meaning a combination of on
and off states (as in a multiple selection).

Text box Allows you, in a rectangular box, view,


type, or edit text or data that is bound to
a cell. A text box can also be a static text
field that presents read-only information.

Comman Runs a macro that performs an action


d button when a user clicks it. A command button
is also referred to as a push button.

Option Allows a single choice within a limited set


button of mutually exclusive choices usually
contained in a group box or frame. An
option button can have one of three
states: selected (turned on), cleared
(turned off), and mixed, meaning a
combination of on and off states (as in a
multiple selection). An option button is
also referred to as a radio button.
Butto Example Description
n
Name

List box Displays a list of one or more items of text


from which a user can choose. Use a list
box for displaying large numbers of
choices that vary in number or content.
There are three types of list boxes:
A single-selection list box enables only
one choice. In this case, a list box
resembles a group of option buttons,
except that a list box can handle a large
number of items more efficiently.
A multiple selection list box enables either
one choice or contiguous (adjacent)
choices.
An extended-selection list box enables
one choice, contiguous choices, and
noncontiguous (or disjointed) choices.

Combo Combines a text box with a list box to


box create a drop-down list box. A combo box
is more compact than a list box, but
requires the user to click the down arrow
to display the list of items. Use to allow a
user to either type an entry or choose
only one item from the list. The control
displays the current value in the text box,
regardless of how that value is entered.

Toggle Indicates a state, such as Yes/No, or a


button mode, such as On/Off. The button
alternates between an enabled and
disabled state when it is clicked.

Spin Increases or decreases a value, such as a


button number increment, time, or date. To
increase the value, click the up arrow; to
decrease the value, click the down arrow.
Typically, a user can also type a text value
into an associated cell or text box.
Butto Example Description
n
Name

Scroll Scrolls through a range of values when


bar you click the scroll arrows or drag the
scroll box. In addition, you can move
through a page (a preset interval) of
values by clicking the area between the
scroll box and either of the scroll arrows.
Typically, a user can also type a text value
directly into an associated cell or text box.

Label Identifies the purpose of a cell or text box,


displays descriptive text (such as titles,
captions, pictures), or provides brief
instructions.

Image Embeds a picture, such as a bitmap, JPEG,


or GIF.

Frame A rectangular object with an optional label


control that groups related controls into one
visual unit. Typically, option buttons,
check boxes, or closely related contents
are grouped in a frame control.
The ActiveX frame control isn't available
in theActiveX Controls section of
the Insert command. However, you can
add the control from the More
Controls dialog box by selecting Microsoft
Forms 2.0 Frame.

More Displays a list of additional ActiveX


Controls controls available on your computer that
you can add to a custom form, such as
Calendar Control 12.0 and Windows Media
Player. You can also register a custom
control in this dialog box.
Top of Page
1.3.2.3 Drawing Tool objects

You may also want to include


SmartArt graphics, Shapes, WordArt, and text boxes on your form. You can resize,
rotate, flip, color, and combine these objects to create even more complex
shapes. When you type text directly in a Shape or text box object, the text
becomes part of that object if you rotate or flip the object, the text rotates or
flips with it. Unlike ActiveX controls, you can assign different attributes, such as
font size and font style, to individual words and characters in the object. You can
also assign macros and add hyperlinks to these objects. You can even link text in
a Shape or text box object to a worksheet cell and dynamically display updated
values in those objects.
Top of Page
1.3.2.4 Working with controls and objects on the worksheet form
After adding forms and ActiveX to a worksheet form, you usually want to fine-
tune and rearrange the controls in a variety of ways to create a well-designed,
user friendly form. Common tasks include the following:

Controlling the display of gridlines while you work with the controls, and
deciding whether to display the gridlines to the user on the final worksheet
form.
Selecting and deselecting controls so that you can specify properties or
make additional adjustments.
Editing text in a control, such as the caption or label.
Grouping, copying, moving, and aligning controls to organize the layout of
the worksheet form.
Resizing and formatting controls to obtain the appearance that you want.
Positioning or sizing a control with a cell.
Protecting controls and linked cells according to your specific data
protection needs.
Enabling or disabling the printing of controls when the worksheet form is
printed.
Deleting unused controls.

You can design a worksheet form with or without cell gridlines in the background.
For example, you might want to turn off cell gridlines and then format all the cells
with the same color or pattern, or even use a picture as a sheet background. To
hide or show the gridlines, on the View tab, in the Show group, clear or select
the Gridlines check box.
Top of Page
1.3.2.5 Determining the type of control that is on your worksheet
Because there are three different types of controls and objects that you can
modify uniquely, you might not know for sure which type of control it is just by
looking at it. To determine the type of control (Form or ActiveX), select and right-
click the control, and then display the shortcut menu:

If the shortcut menu contains the command Properties, the control is an


ActiveX control, and you are in design mode.
If the shortcut menu contains the command Assign Macro, the control is a
Form control.
To display the correct shortcut menu for the group box Form control, make sure
you select the perimeter instead of the interior of the group box.

If the shortcut menu contains the command Edit Text, the object is a
Drawing object.
Top of Page
1.3.3 VBA UserForms
For maximum flexibility, create a UserForm, which is a custom dialog box that
usually includes one or more ActiveX controls. You make UserForms available
from VBA code that you create in the Visual Basic Editor. The high-level steps for
creating a UserForm are as follows:
1. Insert a UserForm into your workbook's VBAProject. You access a
workbook's VBAProject by first displaying the Visual Basic Editor (press
ALT+F11) and then, on the Insert menu in the Visual Basic Editor,
clicking UserForm.
2. Write a procedure to display the UserForm.
3. Add ActiveX controls.
4. Modify properties for the ActiveX controls.
5. Write event-handler procedures for the ActiveX controls.
By using UserForms, you can also utilize advanced form functionality. For
example, you can programmatically add a separate option button for each letter
of the alphabet or you can add a check box for each item in a large list of dates
and numbers.
Before creating a UserForm, consider using built-in dialog boxes available from
Excel that might fit your needs. These built-in dialog boxes include the
VBA InputBox and MsgBoxfunctions, the
Excel InputBox method, GetOpenFilename method, GetSaveAsFilenamemethod,
and the Dialogs object of the Application object, which contains all the built-in
Excel dialog boxes.
For more information, explore the Microsoft Office Excel Developer Center.
2 Select or deselect controls on a worksheet
Applies To: Excel 2016 , Excel 2013 , Excel 2010 , Excel 2007
You can group, copy, resize, or format controls on a worksheet form.
NOTES:

You cannot combine Form controls or ActiveX controls with Drawing Tools or
SmartArt Tools objects (such as Shapes and SmartArt graphics) in the same group
selection.

Make sure the Developer tab is visible on the ribbon. For more information, see Show the
Developer tab. Then make sure the Design mode is enabled. To do this,

click Developer > Design Mode (in Controls group).

When youre done working with controls, you need to turn off Design mode.

2.1 What do you want to do?


Select a single control that is not contained in a group

Select multiple controls that are not contained in a group

Select a single control in a group

Select multiple controls in a group

Select a group that contains controls

Select hidden or stacked controls

Select controls and objects that are on the drawing layer

Cancel the selection of one or more controls

2.2 Select a single control that is not


contained in a group
Click the selection border of the control.
The control border for a Form control appears as a dotted pattern and a series of sizing
handles:

The control border for an ActiveX control appears as a series of sizing handles:

Top of Page

2.3 Select multiple controls that are not


contained in a group
Using the Selection Pane makes it easier to select one or more objects, and to show, hide, or
change the order of objects.

1. On the Home tab, in the Editing group, click Find & Select.

2. Do one of the following:

a. To select objects that are hidden, stacked, or behind text, click Select
Objects, and then draw a box over the objects.

b. To open a task pane where you can select, multiselect, show, hide, or change
the order of objects, click Selection Pane, and then click the options that
you want.

TIP: To select controls using a mouse, press and hold the CTRL key until the controls are
selected.
Top of Page

2.4 Select a single control in a group


1. Click the selection border of the group.

The group selection border appears as a series of sizing handles:

2. Click the control that you want to select inside the group.

Top of Page

2.5 Select multiple controls in a group


1. Click the selection border of the group.

The group selection border appears as a series of sizing handles:

2. Press and hold the CTRL key until the controls are selected.

Top of Page

2.6 Select a group that contains controls


Click the selection border of the group.

The group selection border appears as a series of sizing handles:


Top of Page

2.7 Select hidden or stacked controls


To select a control that is hidden or under other controls:

1. Select the control that is on the top layer.

2. Press TAB to cycle forward or SHIFT+TAB to cycle backward through the controls.

Top of Page

2.8 Select controls and objects that are


on the drawing layer

On the Home tab, in the Editing group, click Find & Select, and then do one
of the following:

a. Click Select Objects, and then use the mouse pointer to draw a rectangle
around the objects that you want to select.

b. Click Selection Pane, and then use the pane to select one or more objects.

Top of Page

2.9 Cancel the selection of one or more


controls
1. Do one of the following:

a. To cancel the selection of one or more controls, click anywhere outside the
control, set of selected controls, or group border.

b. To cancel the selection of one control at a time in a set of selected controls,


hold down CTRL and click the control.
Top of Page

3 Add a list box or combo box to a


worksheet
Applies To: Excel 2007

You use a list box or a combo box, which are similar but slightly different controls, to let
users make multiple choices of items or to enter their own value in a list. Typical examples of
items in these types of lists are employee names, exchange rates, and product items.

3.1 What do you want to do?


Learn about list boxes and combo boxes

Add a list box (Form control)

Add a list box (ActiveX control)

Add a combo box (Form control)

Add a combo box (ActiveX control)

3.2 Learn about list boxes and combo


boxes
List box Displays a list of one or more items of text from which a user can choose.

List box (Form control) List box (ActiveX control)


Combo box Combines a text box with a list box to create a drop-down list box. A combo
box is more compact than a list box, but it requires the user to click the down arrow to display
the list of items. Use a combo box to enable a user either to type an entry or to choose only
one item from a list. The control displays the current value in the text box, regardless of how
that value was entered.

Combo box (Form control) Combo box (ActiveX control)

Top of Page

3.3 Add a list box (Form control)


1. If the Developer tab is not available, display it.

Display the Developer tab

a. Click the Microsoft Office Button , and then click Excel Options.

b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.
The Ribbon is a component of the Microsoft Office Fluent user interface.

2. On the Developer tab, in the Controls group, click Insert, and then under Form
Controls, click List box .

3. Click the worksheet location where you want the upper-left corner of the list box to appear.

4. On the Developer tab, in the Controls group, click Properties .

You can also right-click the control, and then click Format Control.

To specify the control properties, do the following:

a. In the Input range box, enter a cell reference to a range that contains the values to
display in the list box.

b. In the Cell link box, enter a cell reference that contains the list box selection.

The linked cell returns the number of the selected item in the list box. The first item in the range
returns a value of 1, the second item in the range returns a value of 2, and so on.

Use this number in a formula to return the actual item from the input range.

For example, a dessert preference form has a list box that is linked to cell C1, the input range for the
list is D1:D5, and the items in the range are: "Ice Cream" (D1), "Cake" (D2), "Liqueur" (D3), "Candy"
(D4), and "Chocolate" (D5). The following formula, entered in cell B1, returns the value "Liqueur"
from range D1:D5 if the value of C1 is 3, based on the current selection in the list box.

=INDEX(D1:D5,C1)

1. Under Selection type, specify how items can be selected in the list box by doing one of the
following:

o To create a single-selection list box, click Single.

o To create a multiple-selection list box, click Multi.

o To create an extended-selection list box, click Extend.

If you set the selection type to Multi or Extend, the cell that is specified in the Cell link box
returns a value of 0 and is ignored. The Multi and Extend selection types require the use of
Microsoft Visual Basic for Applications (VBA) code. In these cases, consider using the ActiveX list
box control.
Top of Page

3.4 Add a list box (ActiveX control)


1. If the Developer tab is not available, display it.

Display the Developer tab

a. Click the Microsoft Office Button , and then click Excel Options.

b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.

The Ribbon is a component of the Microsoft Office Fluent user interface.

2. On the Developer tab, in the Controls group, click Insert, and then under ActiveX
Controls, click List Box .

3. Click the worksheet location where you want the upper-left corner of the list box to appear.

4. To edit the ActiveX control, make sure that you are in design mode. On the Developer tab,
in the Controls group, turn onDesign Mode .

5. To specify the control properties, on the Developer tab, in the Controls group,
click Properties .

You can also right-click the control, and then click Properties.

The Properties dialog box appears. For detailed information about each property, select the
property, and then press F1 to display a Visual Basic Help topic. You can also type the property name
in the Visual Basic Help Search box. The following section summarizes the properties that are
available.

Summary of properties by functional categories

If you want to specify Use this property

General:
If you want to specify Use this property

Whether the control is loaded when the workbook is opened. (Ignored for ActiveX AutoLoad (Excel)
controls.)

Whether the control can receive the focus and respond to user-generated events. Enabled (Form)

Whether the control can be edited. Locked (Form)

The name of the control. Name (Form)

The way the control is attached to the cells below it (free floating, move but do not size, Placement (Excel)
or move and size).

Whether the control can be printed. PrintObject (Excel)

Whether the control is visible or hidden. Visible (Form)

Text:

Font attributes (bold, italic, size, strikethrough, underline, and weight). Bold, Italic, Size, StrikeTh
m)

The default run time mode of the Input Method Editor (IME). IMEMode (Form)

Whether the size of the control adjusts to display full or partial lines of text. IntegralHeight (Form)

Whether multiple selections of items are permitted. MultiSelect (Form)

The text in the control. Text (Form)

How text is aligned in the control (left, center, or right). TextAlign (Form)

Data and Binding:


If you want to specify Use this property

The range that is linked to the control's value. LinkedCell (Excel)

The content or state of the control. Value (Form)

Size and Position:

The height or width in points. Height, Width (Form)

The distance between the control and the left or top edge of the worksheet. Left, Top (Form)

Formatting:

The background color. BackColor (Form)

The color of the border. BorderColor (Form)

The type of border (none or single-line). BorderStyle (Form)

The foreground color. ForeColor (Form)

Whether the control has a shadow. Shadow (Excel)

The visual appearance of the border (flat, raised, sunken, etched, or bump). SpecialEffect (Form)

Keyboard and Mouse:

A custom mouse icon. MouseIcon (Form)

The type of pointer that is displayed when the user positions the mouse over a particular MousePointer (Form)
object (for example, standard, arrow, or I-beam).
If you want to specify Use this property

Specific to List Box:

The source of data for multiple columns. BoundColumn (Form)

The number of columns to display. ColumnCount (Form)

A single row as a column heading. ColumnHeads (Form)

The width of each column. ColumnWidths (Form)

The range that is used to populate the list. ListFillRange (Excel)

The list style (plain, with option buttons, or with check boxes). ListStyle (Form)

How the control searches its list while the user types (first letter, complete entry, or MatchEntry (Form)
none)

The column to store in the Text property when the user selects a row. TextColumn (Form)

The item that appears in the topmost position in the list. TopIndex (Form)

To create a list box with multiple selection or extended-selection enabled, use


the MultiSelect property. In this case, theLinkedCell property returns a #N/A value. You
must use VBA code to process the multiple selections.

To create a two-column list box with column headers,


set ColumnCount to 2, ColumnHeads to True, ColumnWidths to the width that you
want for each column (for example, 72pt;72pt), ListFillRange to the range that is used to
populate the list (for example, B2:C6), BoundColumn to either 1 or 2 to indicate which
column value to save, and LinkedCell to a cell address that contains the selected value. By
default, the column label is used as the column header (for example, Column B and Column
C). To use your own column headers, place them immediately above the first value specified
in ListFillRange(for example, B1 and C1) before you close the Properties dialog box.
Finally, resize the list box to display both columns.

To create a list box that displays one value in the list box but saves another value in the linked
cell, create a two-column list box, and then hide one of the columns by setting
its ColumnWidths value to 0. For example, you can set up a two-column list box that
contains the names of holidays in one column and dates associated with the holidays in a
second column. To present the holiday names to users, specify the first column as
the TextColumn. To store the dates of the holidays, specify the second column as
the BoundColumn. To hide the dates of the holidays, set the ColumnWidths property of
the second column to 0.

Top of Page

3.5 Add a combo box (Form control)


1. If the Developer tab is not available, display it.

Display the Developer tab

a. Click the Microsoft Office Button , and then click Excel Options.

b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.

The Ribbon is a component of the Microsoft Office Fluent user interface.

2. On the Developer tab, in the Controls group, click Insert, and then under Form
Controls, click Combo box .

3. Click the worksheet location where you want the upper-left corner of the combo box to
appear.

The drop-down arrow is displayed with the text box collapsed.

4. To display the text box, drag the left-center sizing handle to the right.

5. On the Developer tab, in the Controls group, click Properties .

You can also right-click the control, and then click Format Control.

To specify the control properties, do the following:

a. In the Input range box, enter a cell reference to a range that contains the values to
display in the drop-down list of the combo box.
b. In the Cell link box, enter a cell reference that contains the selection in the drop-
down list of the combo box.

The linked cell returns the number of the selected item in the drop-down list of the combo box. The
first item in the range returns a value of 1, the second item in the range returns a value of 2, and so on.

Use this number in a formula to return the actual item from the input range. For example, a dessert
preference form has a combo box linked to cell C1, the input range for the list is D1:D5, and the items
in the range are: "Ice Cream" (D1), "Cake" (D2), "Liqueur" (D3), "Candy" (D4), and "Chocolate"
(D5). The following formula, entered in cell B1, returns the value "Liqueur" from range D1:D5 if the
value of C1 is 3, based on the current selection in the combo box.

=INDEX(D1:D5,C1)

If you want to create a combo box that enables the user to edit the text in the text box, consider using
the ActiveX Combo Boxcontrol.

1. In the Drop-down lines box, enter the number of lines to display in the drop-down list of
the combo box. If the value is:

o 0, it is ignored and treated as 1.

o Less than the number of items in the range specified in the Input range box, a
scroll bar is displayed.

o Equal to or greater than the number of items in the range specified in the Input
range box, no scroll bar is displayed.

Top of Page

3.6 Add a combo box (ActiveX control)


1. If the Developer tab is not available, display it.

Display the Developer tab

a. Click the Microsoft Office Button , and then click Excel Options.

b. In the Popular category, under Top options for working with Excel, select
the Show Developer tab in the Ribboncheck box, and then click OK.

The Ribbon is a component of the Microsoft Office Fluent user interface.

2. On the Developer tab, in the Controls group, click Insert, and then under ActiveX
Controls, click Combo Box .
3. Click the worksheet location where you want the upper-left corner of the combo box to
appear.

4. To edit the ActiveX control, make sure that you are in design mode. On the Developer tab,
in the Controls group, turn onDesign Mode .

5. To specify the control properties, on the Developer tab, in the Controls group,
click Properties .

You can also right-click the control, and then click Properties.

The Properties dialog box appears. For detailed information about each property, select the
property, and then press F1 to display a Visual Basic Help topic. You can also type the property name
in the Visual Basic Help Search box. The following section summarizes the properties that are
available.

Summary of properties by functional categories

If you want to specify Use this property

General:

Whether the control is loaded when the workbook is opened. (Ignored for ActiveX AutoLoad (Excel)
controls.)

Whether the control can receive the focus and respond to user-generated events. Enabled (Form)

Whether the control can be edited. Locked (Form)

The name of the control. Name (Form)

The way the control is attached to the cells below it (free floating, move but do not size, Placement (Excel)
or move and size).

Whether the control can be printed. PrintObject (Excel)


If you want to specify Use this property

Whether the control is visible or hidden. Visible (Form)

Text:

Whether a word or a character is the basic unit used to extend a selection. AutoWordSelect (Form)

Font attributes (bold, italic, size, strikethrough, underline, and weight). Bold, Italic, Size, StrikeTh
m)

Whether selected text remains highlighted when the control does not have the focus. HideSelection (Form)

The default run time mode of the Input Method Editor (IME). IMEMode (Form)

The maximum number of characters a user can enter. MaxLength (Form)

Whether the user can select a line of text by clicking to the left of the text. SelectionMargin (Form)

The text in the control. Text (Form)

How text is aligned in the control (left, center, or right). TextAlign (Form)

Data and binding:

The range that is linked to the control's value. LinkedCell (Excel)

The content or state of the control. Value (Form)

Size and position:

Whether the size of the control automatically adjusts to display all the contents. AutoSize (Form)

The height or width in points. Height, Width (Form)


If you want to specify Use this property

The distance between the control and the left or top edge of the worksheet. Left, Top (Form)

Formatting:

The background color. BackColor (Form)

The background style (transparent or opaque). BackStyle (Form)

The color of the border. BorderColor (Form)

The type of border (none or single-line). BorderStyle (Form)

The foreground color. ForeColor (Form)

Whether the control has a shadow. Shadow (Excel)

The visual appearance of the border (flat, raised, sunken, etched, or bump). SpecialEffect (Form)

Keyboard and mouse:

Whether an automatic tab action occurs after a user has entered the maximum number AutoTab (Form)
of characters for the control.

Whether drag-and-drop is enabled. DragBehavior (Form)

The selection behavior when entering the control (select all or do not change). EnterFieldBehavior (Form

A custom mouse icon. MouseIcon (Form)

The type of pointer that is displayed when the user positions the mouse over a particular MousePointer (Form)
If you want to specify Use this property

object (for example, standard, arrow, or I-beam).

Specific to combo box:

The source of data for multiple columns. BoundColumn (Form)

The number of columns to be displayed. ColumnCount (Form)

A single row as a column heading. ColumnHeads (Form)

The width of each column. ColumnWidths (Form)

The symbol that is displayed on the drop button (down arrow, plain, ellipsis, or DropButtonStyle (Form)
underscore).

The range that is used to populate the list. ListFillRange (Excel)

The maximum number of rows to display in the list. ListRows (Form)

The list style (plain, with option buttons, or with check boxes). ListStyle (Form)

The width of the list. ListWidth (Form)

How the control searches its list while the user types (first letter, complete entry, or MatchEntry (Form)
none)

Whether a value entered as text must match an entry in the existing list. MatchRequired (Form)

When to show the drop button (never, with focus, or always). ShowDropButtonWhen (Fo

How the user chooses or sets the value (drop-down combo or drop-down list). Style (Form)
If you want to specify Use this property

The column to store in the Text property when the user selects a row. TextColumn (Form)

The item that appears in the topmost position in the list. TopIndex (Form)

To create a two-column combo box with column headers,


set ColumnCount to 2, ColumnHeads to True, ColumnWidthsto the width that you
want for each column (for example, 72pt;72pt), ListFillRange to the range that is used to
populate the list (for example, B1:C6), BoundColumn to either 1 or 2 to indicate which
column value to save, TextColumn to the column of data that you want displayed in the text
box section of the combo box (which can be the same as or different from
the BoundColumn value), and LinkedCell to a cell address that will contain the selected
value. By default, the column label is used as the column header (for example, Column B and
Column C). To use your own column headers, place them immediately above the first value
specified in ListFillRange (for example, B1 and C1) before you close
the Propertiesdialog box. Finally, resize the combo box to display both columns.

To create a combo box that displays one value in the combo box but saves another in the
linked cell, create a two-column combo box, and then hide one of the columns by setting
its ColumnWidths value to 0. For example, you can set up a two-column combo box that
contains the names of holidays in one column and associated dates for the holidays in a second
column. To present the holiday names to users, specify the first column as the TextColumn.
To store the dates of the holidays, specify the second column as the BoundColumn. To hide
the dates of the holidays, set the ColumnWidthsproperty of the second column to 0.

To create a combo box that does not enable the user to enter new values, set Style to 2. To
create a combo box that enables a user to enter new values that are not found in the list,
set Style to 1, which is the default. In this case, you must write VBA code if you want to
dynamically update the list values.

Top of Page

4 Fill data automatically in worksheet cells


Applies To: Excel 2010
Instead of entering data manually on a worksheet, you can use the Auto Fill feature to fill cells with
data that follows a pattern or that is based on data in other cells.

This article does not explain how to enter data manually or enter data simultaneously on multiple
worksheets. For information about how to manually enter data, see the article Enter data
manually in worksheet cells.
4.1 What do you want to do?
Automatically repeat values that already exist in the column

Turn off automatic completion of cell values

Use the fill handle to fill data

Hide or display the fill handle

Use Auto Fill Options to change how the selection is filled

Turn Auto Fill Options on or off

Fill data into adjacent cells by using the Fill command

Fill the active cell with the contents of an adjacent cell

Drag the fill handle to fill data into adjacent cells

Fill formulas into adjacent cells

Fill in a series of numbers, dates, or other built-in series items

Fill cells with a series of numbers

Fill data by using a custom fill series

Format numbers as text

Use a custom fill series based on an existing list of items

Use a custom fill series based on a new list of items

Edit or delete a custom fill series

4.2 Automatically repeat values that


already exist in the column
If the first few characters that you type in a cell match an existing entry in that column, Excel
automatically enters the remaining characters for you. Excel automatically completes only those
entries that contain text or a combination of text and numbers. Entries that contain only numbers,
dates, or times are not automatically completed.

After Excel completes what you started typing, do one of the following:

To accept a proposed entry, press ENTER.


The completed entry exactly matches the pattern of uppercase and lowercase letters of the existing
entry.

To replace the automatically entered characters, continue typing.

To delete the automatically entered characters, press BACKSPACE.

NOTE:

Excel completes an entry only when the cursor is at the end of the current cell contents.

Excel bases the list of potential AutoComplete entries on the column that contains the active
cell. Entries that are repeated within a row are not automatically completed.

4.2.1 Turn off automatic completion of cell values


If you don't want Excel to automatically complete cell values, you can turn off this feature.

1. Click the File tab.

2. Under Excel, click Options.

3. Click Advanced, and then under Editing options, clear or select the Enable
AutoComplete for cell values check box to turn automatic completion of cell values on
or off.

Top of Page

4.3 Use the fill handle to fill data


To quickly fill in several types of data series, you can select cells and drag the fill handle . To
use the fill handle, you select the cells that you want to use as a basis for filling additional cells, and
then drag the fill handle across or down the cells that you want to fill.

4.3.1 Hide or display the fill handle


By default, the fill handle is displayed, but you can hide it, or show it if it's hidden.

1. Click the File tab.

2. Under Excel, click Options.

3. Click Advanced, and then under Editing options, clear or select the Enable fill
handle and cell drag-and-drop check box to hide or show the fill handle.

4. To avoid replacing existing data when you drag the fill handle, make sure that the Alert
before overwriting cells check box is selected. If you don't want to see a message about
overwriting nonblank cells, you can clear this check box.
4.3.2 Use Auto Fill Options to change how the selection is filled

After you drag the fill handle, the Auto Fill Options button appears so that you can change how
the selection is filled. For example, you can choose to fill just cell formats by clicking Fill
Formatting Only, or you can choose to fill just the contents of a cell by clicking Fill Without
Formatting.

4.3.3 Turn Auto Fill Options on or off


If you don't want to display the Auto Fill Options button every time that you drag the fill handle,
you can turn it off. Likewise, if the Auto Fill Options button does not appear when you drag the fill
handle, you might want to turn it on.

1. Click the File tab.

2. Under Excel, click Options.

3. Click Advanced, and then under Cut, copy, and paste, clear the Show Paste Options
button when content is pastedcheck box.

Top of Page

4.4 Fill data into adjacent cells by using


the Fill command
You can use the Fill command to fill the active cell or a selected range with the contents of an adjacent
cell or range, or you can quickly fill adjacent cells by dragging the fill handle .

4.4.1 Fill the active cell with the contents of an adjacent cell
1. Select an empty cell that is below, to the right, above, or to the left of the cell that contains the
data that you want to use to fill the empty cell.

2. On the Home tab, in the Editing group, click Fill, and then click Down, Right, Up,
or Left.

TIP: To quickly fill a cell with the contents of an adjacent cell, you can press CTRL+D to fill
from the cell above or CTRL+R to fill from the cell to the left. To fill a cell with the contents
of a cell below it (that is, to fill up), on the Home tab, in the Editing group, click Fill, and
then click Up. To fill a cell with the contents of a cell to the right (fill left), on the Home tab,
in the Editing group, click Fill, and then click Left.
4.4.2 Drag the fill handle to fill data into adjacent cells
1. Select the cells that contain the data that you want to fill into adjacent cells.

2. Drag the fill handle across the cells that you want to fill.

3. To change how you want to fill the selection, click Auto Fill Options , and then click
the option that you want.

NOTE: If you drag the fill handle up or to the left of a selection and stop in the selected cells
without going past the first column or the top row in the selection, Excel deletes the data
within the selection. You must drag the fill handle out of the selected area before releasing the
mouse button.

Top of Page

4.5 Fill formulas into adjacent cells


1. Select the cell that contains the formula that you want to fill into adjacent cells.

2. Drag the fill handle across the cells that you want to fill.

3. To choose how you want to fill the selection, click Auto Fill Options , and then click
the option that you want.

NOTE: If automatic workbook calculation is not enabled, formulas will not recalculate when
you fill cells. To check your workbook calculation options, do the following:

4. Click the File tab.

5. Under Excel, click Options, and then click the Formulas category.

6. Under Calculation options, look under Workbook Calculation.

o Automatic Formulas automatically recalculate.

o Automatic except for data tables Formulas recalculate, unless the formula is in a
data table.

o Manual Formulas never recalculate automatically.

o Recalculate workbook before saving This option is available only if Workbook


Calculation is set to Manual. If this check box is selected, formulas do not
automatically recalculate until you save the workbook. Note that several other actions
can cause the workbook to be saved, such as using the Send To command.

4.5.1 Tips
You can also fill the active cell with the formula of an adjacent cell by using the Fill command
(on the Home tab in theEditing group), or by pressing CTRL+D to fill a cell below or
CTRL+R to fill a cell to the right of the cell containing the formula.

You can automatically fill a formula downward, for all adjacent cells that it applies to, by
double-clicking the fill handle of the first cell that contains the formula. For example, cells
A1:A15 and B1:B15 contain numbers, and you type the formula=A1+B1 in cell C1. To copy
that formula into cells C2:C15, select cell C1 and double-click the fill handle.

Top of Page

4.6 Fill in a series of numbers, dates, or


other built-in series items
Using the fill handle, you can quickly fill cells in a range with a series of numbers or dates, or with a
built-in series for days, weekdays, months, or years.

1. Select the first cell in the range that you want to fill.

2. Type the starting value for the series.

3. Type a value in the next cell to establish a pattern.

For example, if you want the series 1, 2, 3, 4, 5..., type 1 and 2 in the first two cells. If you want the
series 2, 4, 6, 8..., type 2and 4. If you want the series 2, 2, 2, 2..., you can leave the second cell blank.

More examples of series that you can fill

When you fill a series, the selections are extended as shown in the following table. In this table, items
that are separated by commas are contained in individual adjacent cells on the worksheet.

Initial selection Extended series

1, 2, 3 4, 5, 6,...

9:00 10:00, 11:00, 12:00,...

Mon Tue, Wed, Thu,...

Monday Tuesday, Wednesday, Thursday,...

Jan Feb, Mar, Apr,...


Initial selection Extended series

Jan, Apr Jul, Oct, Jan,...

Jan-07, Apr-07 Jul-07, Oct-07, Jan-08,...

15-Jan, 15-Apr 15-Jul, 15-Oct,...

2007, 2008 2009, 2010, 2011,...

1-Jan, 1-Mar 1-May, 1-Jul, 1-Sep,...

Qtr3 (or Q3 or Quarter3) Qtr4, Qtr1, Qtr2,...

text1, textA text2, textA, text3, textA,...

1st Period 2nd Period, 3rd Period,...

Product 1 Product 2, Product 3,...

1. Select the cell or cells that contain the starting values.

2. Drag the fill handle across the range that you want to fill.

To fill in increasing order, drag down or to the right. To fill in decreasing order, drag up or to the left.

4.6.1 Tips

You can also specify the type of series by using the right mouse button to drag the fill handle
over the range and then clicking the appropriate command on the shortcut menu. For example,
if the starting value is the date JAN-2007, click Fill Months for the series FEB-2007, MAR-
2007, and so on; or click Fill Years for the series JAN-2007, JAN-2008, and so on.

If the selection contains numbers, you can control the type of series that you want to create.

Top of Page
4.7 Fill cells with a series of numbers
1. On the Home tab, in the Editing group, click Fill, and then click Series.

2. Under Type, click one of the following options:

o Linear Creates a series that is calculated by adding the value in the Step
value box to each cell value in turn.

o Growth Creates a series that is calculated by multiplying the value in the Step
value box by each cell value in turn.

o Date Creates a series that fills date values incrementally by the value in the Step
value box and is dependent on the unit specified under Date unit.

o AutoFill Creates a series that produces the same results as dragging the fill handle.

3. You can suppress series AutoFill by holding down CTRL as you drag the fill handle of a
selection of two or more cells. The selected values are then copied to the adjacent cells, and
Excel does not extend a series.

4.8 Fill data by using a custom fill series


To make entering a particular sequence of data (such as a list of names or sales regions) easier, you can
create a custom fill series. A custom fill series can be based on a list of existing items on a worksheet,
or you can type the list from scratch. You cannot edit or delete a built-in fill series (such as a fill series
for months and days), but you can edit or delete a custom fill series.

NOTE: A custom list can only contain text or text mixed with numbers. For a custom list that
contains numbers only, such as 0 through 100, you must first create a list of numbers that is
formatted as text.

4.8.1 Format numbers as text


1. Select enough cells for the list of numbers that you want to format as text.

2. On the Home tab, in the Number group, click the arrow on the Number Format box,
and then click Text.
TIP: You might have to click More Number Formats to see the Text format in the list.

1. In the formatted cells, type the list of numbers.

4.8.2 Use a custom fill series based on an existing list of items


1. On the worksheet, select the list of items that you want to use in the fill series.

2. Click the File tab.

3. Under Excel, click Options.

4. Click Advanced, and then under General, click Edit Custom Lists.

5. Verify that the cell reference of the list of items that you selected is displayed in the Import
list from cells box, and then click Import.

The items in the list that you selected are added to the Custom lists box.

6. Click OK twice.

7. On the worksheet, click a cell, and then type the item in the custom fill series that you want to
use to start the list.

8. Drag the fill handle across the cells that you want to fill.

4.8.3 Use a custom fill series based on a new list of items


1. Click the File tab.

2. Under Excel, click Options.

3. Click Advanced, and then under General, click Edit Custom Lists.

4. In the Custom lists box, click NEW LIST, and then type the entries in the List
entries box, starting with the first entry.

5. Press ENTER after each entry.

6. When the list is complete, click Add, and then click OK twice.

7. On the worksheet, click a cell, and then type the item in the custom fill series that you want to
use to start the list.
8. Drag the fill handle across the cells that you want to fill.

4.8.4 Edit or delete a custom fill series


1. Click the File tab.

2. Under Excel, click Options.

3. Click Advanced category, and then under General, click Edit Custom Lists.

4. In the Custom lists box, select the list that you want to edit or delete, and then do one of the
following:

o To edit the fill series, make the changes that you want in the List entries box, and
then click Add.

o To delete the fill series, click Delete.

Top of Page

5 ControlSource Property
Applies To: Access 2007

5.1 Applies to

BoundObjectFrame Object ListBox Object

CheckBox Object OptionButton Object

ComboBox Object OptionGroup Object

CustomControl Object TextBox Object

GroupLevel Object ToggleButton Object

You can use the ControlSource property to specify what data appears in a control. You can display
and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an
expression. Read/write String.

expressio n.ControlSource
expression Required. An expression that returns one of the objects in the Applies To list.

5.2 Setting
The ControlSource property uses the following settings.

Setting Description

A field The control is bound to a field in a table, query, or SQL statement. Data from the field is displayed in
name inside the control change the corresponding data in the field. (To make the control read-only, set the L
click a control bound to a field that has a Hyperlink data type, you jump to the destination specified in th

An The control displays data generated by an expression. This data can be changed by the user but isn't save
expression

You can set the ControlSource property for a control by using the control's property sheet, a macro,
or Visual Basic for Applications (VBA) code.

You can also set the ControlSource property for a text box by typing a field name or expression
directly in the text box in form Design view or report Design view.

For a report, you can set this property by selecting a field or typing an expression in the
Field/Expression pop-up window in the Group, Sort and Total pane.

In VBA, use a string expression to set the value of this property.

5.3 Remarks
For a report group level, the ControlSource property determines the field or expression to group on.

NOTE: The ControlSource property doesn't apply to check box, option button, or toggle
button controls in an option group. It applies only to the option group itself.

For reports, the ControlSource property applies only to report group levels.

Forms and reports act as "windows" into your database. You specify the primary source of data for a
form or report by setting its RecordSource property to a table, query, or SQL statement. You can then
set the ControlSource property to a field in the source of data or to an expression. If
the ControlSource property setting is an expression, the value displayed is read-only and not saved
in the database. For example, you can use the following settings.
Sam ple setting Description

LastName For a control, data from the LastName field is displayed in the control. For
Office Access 2007 groups the data on last name.

=Date( ) + 7 For a control, this expression displays a date seven days from today in the co

=DatePart("q",ShippedDate) For a control, this expression displays the quarter of the shipped date. Fo
groups the data on the quarter of the shipped date.

5.4 Example
The following example sets the ControlSource property for a text box named AddressPart to a field
named City:

Forms!Customers!AddressPart.ControlSource = "City"

The next example sets the ControlSource property for a text box named Expected to the
expression =Date() + 7.

Me!Expected.ControlSource = "=Date() + 7"

5.5 Create a grouped or summary report


Applies To: Access 2016 , Access 2013 , Access 2010
Information is often easier to understand when it is divided into groups. For
example, a report that groups sales by region can highlight trends that otherwise
might go unnoticed. In addition, placing totals (such as sums or averages) at the
end of each group in your report can replace a lot of manual interaction with a
calculator.
Access makes working with grouped reports easy. You can create a basic grouped
report by using the Report Wizard, you can add grouping and sorting to an
existing report, or you can revise grouping and sorting options that have already
been defined.
NOTE: This article doesnt apply to Access web apps the kind of database you
design with Access and publish online. See Create an Access appfor more
information.
5.6 In this article
Create a quick grouped or sorted report

Build a new grouped report by using the Report Wizard

Add or modify grouping and sorting in an existing report

5.7 Create a quick grouped or sorted


report
Even if youre new to grouped reports, you can quickly create a simple one by using the following
procedure:

1. In the Navigation Pane, select a table or query that contains the records you want on your
report.

2. On the Create tab, click Report.

Access creates a simple tabular report and then displays it in Layout View. If there are many
fields in the report, it will probably extend across more than one page. Before applying any
grouping or sorting, you might want to resize columns (and delete unwanted columns) so that
the report fits on one page width. To delete a column, right-click it and then click Delete
Column.

3. Right click a column on which you want to group or sort, and then click Group On [field
name] or click one of the Sortoptions. For example, to group on the Priority column, right-
click the Priority column and then click Group On Priority.

When applying grouping, Access moves the grouping field to the leftmost column, and groups
the remaining columns based on that column. In some cases, Access also adds a grand total to
the Report Footer section.

4. Optionally, view and fine-tune your grouping and sorting options by following the procedures
in the section, Add or modify grouping and sorting in an existing report.

Top of the Document

5.8 Build a new grouped report by using


the Report Wizard
NOTE: Reports created by using the Report Wizard are not compatible with the Publish to
Access Services feature of Access 2010. For more information about the Publish to Access
Services feature, see the article Build an Access database to share on the Web.
The Report Wizard presents you with a series of questions, and then generates a report based on your
answers. Among those questions is one that asks for the field or fields to use to group your report.
After the report is created, you can use it as-is or modify it to better suit your needs. Before you begin
with the Report Wizard, you need to decide upon a data source.

5.8.1 Start the Report Wizard


1. On the Create tab, in the Reports group, click Report Wizard.

Access starts the Report Wizard.

2. Click the Tables/Queries drop-down list and choose the table or query that contains the
fields you want on your report.

3. Double-click fields in the Available Fields list to choose them.

Access moves them to the Selected Fields list. Alternatively, you can click the buttons located
between the Available Fields box and the Selected Fields box to add or remove the selected
field or to add all or remove all of the fields.

4. If there are fields in another table or query that you also want to put on your report, click
the Tables/Queries drop-down list again and choose the other table or query, and continue
to add fields.

5. After you've finished adding fields, click Next.

5.8.2 Group records in the Report Wizard


Grouping lets you organize and arrange records by group, such as by Region or SalesPerson. Groups
can be nested so that you can easily identify the relationships among the groups and find the
information you want quickly. You can also use grouping to calculate summary information, such as
totals and percentages.
When you include more than one table in a report, the wizard examines the relationships between the
tables and determines how you might want to view the information.

1. On the page of the Report Wizard that asks Do you want to add any grouping
levels?, click one of the field names in the list, and then click Next.

2. To add grouping levels, double-click any of the field names in the list to add them to your
report.

You can also remove a grouping level by double-clicking it in the page display on the right side of the
dialog box. Use the arrow buttons to add and remove grouping levels, and adjust the priority of a
grouping level by selecting it and clicking the up or down priority buttons. Access adds each grouping
level and shows it nested within its parent grouping level.

3. Click Grouping Options to display the Grouping Intervals dialog box.

4. Optionally, for each group-level field, choose a grouping interval.

The grouping interval lets you customize how records are grouped. In the previous illustration, records
are grouped on the ShippedDate field, which is a Date/Time data type. The Report Wizard offers
choices appropriate to the field type in the Grouping intervals list. Thus, because ShippedDate is a
Date/Time type, you can choose to group by actual value
(Normal), Year, Quarter, Month, Week, Day, Hour and Minute. If the field were a Text data
type, you could choose to group by the entire field (Normal), or perhaps by the first one to five
characters. For a numeric data type, you can choose to group by value ( Normal), or by range in
selected increments.

After selecting a grouping interval, click OK.

5. Click Next to navigate to the next page of the wizard.

5.8.3 Sort and summarize records


You can sort records by up to four fields, in either ascending or descending order.

1. Click the first drop-down list and choose a field on which to sort.

You can click the button to the right of the list to toggle between ascending and descending order
(Ascending is the default). Optionally, click the second, third, and fourth drop-down lists to choose
additional sort fields.

2. Click Summary Options if you want to summarize any of the numeric fields.

Note that the Summary Options button will only be visible if you have one or more numeric fields
in the Detail section your report. The wizard displays the available numeric fields.
3. Select the check box under your choice of Sum, Avg, Min or Max to include those
calculations in the group footer.

You can also choose to show the details and summary or the summary only. In the latter case, totals for
each ShippedDate value are shown (if you selected the check box for Sum, for example), but the
order detail is omitted. You can also choose to show percent of total calculations for sums.

4. Click OK.

5. Follow the directions on the remaining pages of the Report Wizard. On the last page, you can
edit the title of the report. This title will be displayed on the first page of the report, and
Access will also save the report, using the title as the document name. You can edit both the
title and the document name later.

6. Click Finish. Access automatically saves the report and displays it in Print Preview, which
shows you the report as it will look when printed.

You can use the navigation buttons at the bottom of the preview pane to view the pages of the report
sequentially or jump to any page in the report. Click one of the navigation buttons or type the page
number that you want to see in the page number box, and then press ENTER.

In Print Preview, you can zoom in to see details or zoom out to see how well data is positioned on the
page. With the mouse pointer positioned over the report, click once. To reverse the effect of the zoom,
click again. You can also use the zoom control in the status bar.

Top of the Document

5.9 Add or modify grouping and sorting


in an existing report
If you have an existing report and you want to add sorting or grouping to it, or if you want to modify
the report's existing sorting or grouping, this section helps you get started.

5.9.1 Add grouping, sorting, and totals


You can perform simple sorting, grouping and totaling operations by right-clicking fields in Layout
view and then choosing the operation you want from the shortcut menu. To switch to Layout view,
right-click the report in the Navigation Pane and then click Layout view.

NOTE: Although the instructions in this section don't use the Group, Sort, and Total pane
directly, it is a good idea to open the pane and observe how it changes as you work. You will
get a better idea of what Access is doing and, as you get more comfortable working with
the Group, Sort, and Total pane, you can use it to make additional adjustments to your
report. To display the Group, Sort, and Total pane:

On the Design tab, in the Grouping & Totals group, click Group & Sort.

5.9.1.1 Sort on a single field

Right-click any value in the field on which you want to sort.

On the shortcut menu, click the sort option you want. For example, to sort a text field in
ascending order, click Sort A to Z. To sort a numeric field in descending order, click Sort
Largest to Smallest.

Access sorts the report as you specified. If the Group, Sort, and Total pane is open, you can see
that a new Sort by line for the field has been added.

5.9.1.2 Sort on multiple fields

NOTE: When you apply sorting by right-clicking a field in Layout view, you can only sort one
field at a time. Applying sorting to another field removes the sorting on the first field. This
differs from the sorting behavior in forms, where multiple sort orders can be established by
right-clicking each field in turn and the choosing the sort order you want. To create multiple
sorting levels, see the section Add grouping, sorting, and totals by using the Group, Sort,
and Total pane.

5.9.1.3 Group on a field

Right-click any value in the field on which you want to group.

On the shortcut menu, click Group On.

Access adds the grouping level and creates a group header for it. If the Group, Sort, and
Total pane is open, you can see that a new Group on line for the field is added.

5.9.1.4 Add a total to a field


This option lets you calculate a sum, average, count, or other aggregate for a field. A grand total is
added to the end of the report, and group totals are added to any groups that exist on the report.

Right-click any value in the field that you want to total.

Click Total.
Click the operation you would like to perform: Sum, Average, Count Records (to count
all records), Count Values (to count only the records with a value in this
field), Max, Min, Standard Deviation, or Variance.

Access adds a calculated text box control to the report footer, which creates a grand total. Also, if your
report has any grouping levels, Access adds group footers (if not already present) and places the total
in each footer.

NOTE: You can also add totals by clicking the field that you want totaled and then, on
the Design tab, in the Grouping & Totals group, clickTotals.

5.9.2 Add grouping, sorting, and totals by using the Group, Sort, and Total pane
Working in the Group, Sort, and Total pane gives you the most flexibility when you want to add
or modify groups, sort orders, or totals options on a report. Again, Layout view is the preferred view in
which to work because it is much easier to see how your changes affect the display of the data.

5.9.3 Display the Group, Sort, and Total pane

On the Design tab, in the Grouping & Totals group, click Group & Sort.

Access displays the Group, Sort, and Total pane.

To add a new sorting or grouping level, click Add a group or Add a sort.

A new line is added to the Group, Sort, and Total pane, and a list of available fields is displayed.

You can click one of these field names or you can click expression below the list of fields to enter
an expression. Once you choose a field or enter an expression, Access adds the grouping level to the
report. In Layout view, the display changes immediately to show the grouping or sort order.

For more information about creating expressions, see the article Create an expression.

NOTES:
If there are already several sorting or grouping levels defined, you may need to scroll down in
the Group, Sort, and Totalpane before you can see the Add a group and Add a
sort buttons.

You can define up to 10 grouping and sorting levels in a report.

5.9.4 Change grouping options


Each sorting or grouping level has a number of options that can be set to obtain the results you want.

To display all the options for a grouping or sorting level, click More on the level that you
want to change.

To hide the options, click Less.

Sort order You can change the sort order by clicking the sort order drop-down list, then clicking the
option you want.

Group interval This setting determines how the records are grouped together. For example, you can
group on the first character of a text field so that all that start with "A" are grouped together, all that
start with "B" are grouped together, and so on. For a date field, you can group by day, week, month,
quarter, or you can enter a custom interval.

Totals To add totals, click this option. You can add totals on multiple fields, and you can do multiple
types of totals on the same field.
Click the Total On drop-down arrow and select the field you want to have summarized.

Click the Type drop-down arrow and select the type of calculation to perform.

Select Show Grand Total to add a grand total to the end of the report (in the report footer).

Select Show group totals as % of Grand Total to add a control to the group footer that
calculates the percentage of the grand total for each group.

Select Show in group header or Show in group footer to display the total in the
desired location.

Once all the options have been chosen for a field, you can repeat the process and summarize another
field by selecting the other field from the Total On drop-down list. Otherwise, click outside
the Totals pop-up window to close it.

Title This allows you to change the title of the field being summarized. This is used for the column
heading and for labeling summary fields in headers and footers.

To add or modify the title:

Click the blue text following with title.

The Zoom dialog box appears.

Type the new title in the dialog box, and then click OK.

With/without a header section Use this setting to add or remove the header section that precedes
each group. When adding a header section, Access moves the grouping field to the header for you.
When you remove a header section that contains controls other than the grouping field, Access asks
for confirmation to delete the controls.

With/without a footer section Use this setting to add or remove the footer section that follows each
group. When you remove a footer section that contains controls, Access asks for confirmation to delete
the controls.

Keep group together This setting determines how groups are laid out on the page when the report is
printed. You may want to keep groups together as much as possible to reduce the amount of page
turning that is needed to see the entire group. However, this usually increases the amount of paper
needed to print the report, because most pages will have some blank space at the bottom.

Do not keep group together on one page Use this option if you are not concerned about
groups being broken up by page breaks. For example, a group of 30 items may have 10 items
on the bottom of one page and the remaining 20 items at the top of the next page.

Keep whole group together on one page This option helps minimize the number of page
breaks in a group. If a group cannot fit in the remaining space on a page, Access leaves that
space blank and begins the group on the next page instead. Large groups may still span
multiple pages, but this option minimizes the number of page breaks within the group as much
as possible.

Keep header and first record together on one page For groups with group headers, this
ensures that the group header will not print by itself at the bottom of a page. If Access
determines that there is not enough room for at least one row of data to be printed after the
header, the group begins on the following page.

5.9.5 Change the priority of grouping and sorting levels


To change the priority of a grouping or sorting level, click the row in the Group, Sort, and
Total pane and then click the up arrow or the down arrow on the right side of the row.

5.9.6 Delete grouping and sorting levels


To delete a grouping or sorting level, click the row you want to delete in the Group, Sort, and
Total pane, and then press DELETE or click the Delete button on the right side of the row. When
you delete a grouping level, if the grouping field was in the group header or footer, Access moves it to
the report's Detail section. Any other controls that were in the group header or group footer are
deleted.

5.9.7 Create a summary report (without record details)


If you want to show only totals (that is, just the information in header and footer rows), on
the Design tab, in the Grouping & Totals group, click Hide Details. Doing this hides the
records at the next lower level of grouping, resulting in a much more compact presentation of the
summary data. Although the records are hidden, the controls in the hidden section are not deleted.
Click Hide Details again to restore the Detail rows to the report.

Top of the Document

6 Select or deselect controls on a worksheet


Applies To: Excel 2016 , Excel 2013 , Excel 2010 , Excel 2007
You can group, copy, resize, or format controls on a worksheet form.

NOTES:

You cannot combine Form controls or ActiveX controls with Drawing Tools or SmartArt
Tools objects (such as Shapes and SmartArt graphics) in the same group selection.

Make sure the Developer tab is visible on the ribbon. For more information, see Show the
Developer tab. Then make sure the Design mode is enabled. To do this,
click Developer > Design Mode (in Controls group).
When youre done working with controls, you need to turn off Design mode.

6.1 What do you want to do?


Select a single control that is not contained in a group

Select multiple controls that are not contained in a group

Select a single control in a group

Select multiple controls in a group

Select a group that contains controls

Select hidden or stacked controls

Select controls and objects that are on the drawing layer

Cancel the selection of one or more controls

6.2 Select a single control that is not


contained in a group
Click the selection border of the control.

The control border for a Form control appears as a dotted pattern and a series of sizing handles:

The control border for an ActiveX control appears as a series of sizing handles:
Top of Page

6.3 Select multiple controls that are not


contained in a group
Using the Selection Pane makes it easier to select one or more objects, and to show, hide, or change
the order of objects.

1. On the Home tab, in the Editing group, click Find & Select.

2. Do one of the following:

a. To select objects that are hidden, stacked, or behind text, click Select Objects, and
then draw a box over the objects.

b. To open a task pane where you can select, multiselect, show, hide, or change the order
of objects, click Selection Pane, and then click the options that you want.

TIP: To select controls using a mouse, press and hold the CTRL key until the controls are
selected.

Top of Page

6.4 Select a single control in a group


1. Click the selection border of the group.

The group selection border appears as a series of sizing handles:

2. Click the control that you want to select inside the group.

Top of Page
6.5 Select multiple controls in a group
1. Click the selection border of the group.

The group selection border appears as a series of sizing handles:

2. Press and hold the CTRL key until the controls are selected.

Top of Page

6.6 Select a group that contains controls


Click the selection border of the group.

The group selection border appears as a series of sizing handles:

Top of Page

6.7 Select hidden or stacked controls


To select a control that is hidden or under other controls:

1. Select the control that is on the top layer.

2. Press TAB to cycle forward or SHIFT+TAB to cycle backward through the controls.

Top of Page
6.8 Select controls and objects that are
on the drawing layer
On the Home tab, in the Editing group, click Find & Select, and then do one of the
following:

a. Click Select Objects, and then use the mouse pointer to draw a rectangle around
the objects that you want to select.

b. Click Selection Pane, and then use the pane to select one or more objects.

Top of Page

6.9 Cancel the selection of one or more


controls
1. Do one of the following:

a. To cancel the selection of one or more controls, click anywhere outside the control, set
of selected controls, or group border.

b. To cancel the selection of one control at a time in a set of selected controls, hold down
CTRL and click the control.

Top of Page

7 Add a list box or combo box to a


worksheet in Excel 2016 for Windows
Applies To: Excel 2016

When you want to display a list of values that


users can choose from, add a list box to your
worksheet.
7.1 Add a list box to a worksheet
1. Create a list of items that you want to displayed in your list box like
in this picture.

2. Click Developer > Insert.

NOTE: If the Developer tab isn't visible, click File > Options > Customize Ribbon. In
the Main Tabs list, check the Developer box, and then click OK.

3. Under Form Controls, click List box (Form Control).

4. Click the cell where you want to create the list box.

5. Click Properties > Control and set the required properties:


o In the Input range box, type the range of cells containing the
values list.

NOTE: If you want more items displayed in the list box, you can change the font size of
text in the list.

o In the Cell link box, type a cell reference.

TIP: The cell you choose will have a number associated with the item selected in your
list box, and you can use that number in a formula to return the actual item from the
input range.

o Under Selection type, pick a Single and click OK.

NOTE: If you want to use Multi or Extend, consider using an ActiveX list box control.

7.2 Add a combo box to a worksheet

You can make data entry easier by letting


users choose a value from a combo box. A
combo box combines a text box with a list box
to create a drop-down list.
You can add a Form Control or an ActiveX
Control combo box. If you want to create a
combo box that enables the user to edit the
text in the text box, consider using the ActiveX
Combo Box. The ActiveX Control combo box is
more versatile because, you can change font
properties to make the text easier to read on a
zoomed worksheet and use programming to
make it appear in cells that contain a data
validation list.
1. Pick a column that you can hide on the worksheet and create a list
by typing one value per cell.

NOTE: You can also create the list on another worksheet in the same workbook.

2. Click Developer > Insert.

NOTE: If the Developer tab isn't visible, click File > Options > Customize Ribbon. In
the Main Tabs list, check the Developer box, and then click OK.

3. Pick the type of combo box you want to add:

o Under Form Controls, click Combo box (Form Control).

Or
o Under ActiveX Controls, click Combo Box (ActiveX Control).

4. Click the cell where you want to add the combo box and drag to
draw it.

TIPS: To resize the box, point to one of the resize handles, and drag the edge of the
control until it reaches the height or width you want.

To move a combo box to another worksheet


location, select the box and drag it to another
location.

7.3 Format a Form Control combo box


1. Right-click the combo box and pick Format Control.

2. Click Control and set the following options:


o Input range: Type the range of cells containing the list of
items.

o Cell link: The combo box can be linked to a cell where the item
number is displayed when you select an item from the list. Type the cell
number where you want the item number displayed.

For example, cell C1 displays 3 when the item Sorbet is selected, because
it's the third item in our list.

TIP: You can use the INDEX function to show an item name instead of a number. In our
example, the combo box is linked to cell B1 and the cell range for the list is A1:A2. If
the following formula, is typed into cell C1: =INDEX(A1:A5,B1), when we select the
item "Sorbet" is displayed in C1.
o Drop-down lines: The number of lines you want displayed
when the down arrow is clicked. For example, if your list has 10 items and
you don't want to scroll you can change the default number to 10. If you
type a number that's less than the number of items in your list, a scroll bar
is displayed.

3. Click OK.

7.4 Format an ActiveX combo box


1. Click Developer > Design Mode.

2. Right-click the combo box and pick Properties, click Alphabetic, and
change any property setting that you want.

Here's how to set properties for the combo box in this picture:
To set this property Do this

Fill color Click BackColor > the down arrow > Pallet, and
then pick a color.

Font type, style or size Click Font > the... button and pick font type, size,
or style.
To set this property Do this

Font color Click ForeColor > the down arrow > Pallet, and then
pick a color.

Link a cell to display Click LinkedCell


selected list value.

Link Combo Box to a list Click the box next to ListFillRange and type the cell
range for the list.

Change the number of list Click the ListRows box and type the number of
items displayed items to be displayed.

3. Close the Property box and click Designer Mode.

4. After you complete the formatting, you can right-click the column
that has the list and pickHide.

7.4.1 Employee Database Edit and Delete from a Userform

www.onlinepclearning.com/edit-and-delete-from-a-...
1.
2.

Prevedi ovu stranicu

This information can be applied to any Listbox userform that is populated ... we canedit and
delete information in a database from a Excel VBA userform. ... Make sure that you do
not use the click event for this action, it should be double-click.

S-ar putea să vă placă și