0% found this document useful (0 votes)
48 views12 pages

Creating Custom Workbook Elements

The document provides a comprehensive guide on creating and modifying custom workbook elements in Excel, including themes, color formats, font formats, and cell styles. It outlines step-by-step instructions for applying these customizations, as well as recording and modifying basic macros to automate repetitive tasks. The document emphasizes the importance of themes and styles in achieving a consistent and professional look across Excel workbooks.

Uploaded by

antoniofreches
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views12 pages

Creating Custom Workbook Elements

The document provides a comprehensive guide on creating and modifying custom workbook elements in Excel, including themes, color formats, font formats, and cell styles. It outlines step-by-step instructions for applying these customizations, as well as recording and modifying basic macros to automate repetitive tasks. The document emphasizes the importance of themes and styles in achieving a consistent and professional look across Excel workbooks.

Uploaded by

antoniofreches
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

OneNote [Link]

Creating Custom Workbook Elements

In Excel, you can create and modify custom workbook elements such as themes, color
formats, font formats, cell styles, macros, and form controls. Options for customizing cell
styles, themes, colors, and fonts are located on the Home and Page Layout tabs of the
Ribbon. You must add the Developer tab to the Ribbon to access commands for creating
macros and inserting form controls.
Creating and Modifying Custom Themes
A document theme is a predefined set of colors, fonts, and effects that can be applied to
a workbook. You can use document themes to easily format an entire document and give
it a fresh, professional look. Themes are also used in other Office applications, such as
Microsoft Word and Microsoft PowerPoint, enabling you to give all your Office
documents a uniform look in terms of colors, fonts, and effects. (Effects, such as shadows
or bevels, modify the appearance of an object.)
Excel has several predefined document themes. When you apply a theme to a workbook,
the colors, fonts, and effects contained within that theme replace any styles that were
already applied to cells or ranges. You can modify predefined themes to create a custom
theme.

STEP BY STEP Create and Modify Custom Themes


GET READY. LAUNCH Excel if it is not already open.
1. OPEN the 02 [Link] workbook from the data files for this lesson.
2. SAVE the workbook as 02 Themes [Link] in the lesson folder on your flash
drive.
3. With Sheet1 active, click cell A3.
4. On the Home tab, in the Styles group, click the Cell Styles button and select 20%
Accent4. A light purple background is applied to the cell range, the font size is
reduced, and the font color changes to black.
5. Click the Page Layout tab, and then in the Themes group, click the Themes button
to open the Themes gallery. Several built-in themes appear in the gallery. Move your
mouse pointer over each theme to display its effect on the underlying worksheet,
which is referred to as Live Preview.
6. Point to the Savon theme, as shown in Figure 2-15. Click Savon. You just changed
the default document theme to the Savon theme. The font for subheadings and
general data changed from Calibri to Century Gothic, and the background in rows 2
and 3 changed to different colors.

Figure 2-15: The Themes gallery with a preview of the Savon theme displayed
in the worksheet
7. Click Sheet2. Notice that the font changed on that sheet as well.
8. Click Sheet1 to return to the main worksheet. Click the Home tab, and then in the
Styles group, click the Cell Styles button to display the Cell Styles gallery. Notice
that the color schemes for the various groups have changed. This is because a new

1 de 12 14/04/2021, 14:32
OneNote [Link]

document theme has been applied, and several built-in cell styles were created
using theme fonts and colors.
9. Click the Page Layout tab, and then in the Themes group, click the Colors button.
Excel displays a variety of color schemes that you can apply to the current Savon
design theme. Point to Red Orange to display a preview of the new colors in the
worksheet (Figure 2-16).

Figure 2-16: The Colors gallery with a preview of the Red Orange color scheme
displayed in the worksheet
10. From the Colors menu, click the Red Orange option. The fill colors in rows 2 and 3
have changed, but the fonts on both worksheets remain the same.
11. SAVE the 02 Themes [Link] workbook and then CLOSE the workbook.
PAUSE. LEAVE Excel open for the next exercise.

The default document theme in Excel 2016 is named Office. Document themes are
consistent in all Microsoft Office 2016 programs. Applying a new theme changes fonts
and colors, and the color of shapes and SmartArt, tables, charts, and other objects.
Remember that cell styles are used to format specific cells or ranges within a worksheet;
document themes are used to apply sets of styles (colors, fonts, and fill effects) to an
entire document.
Many built-in cell styles use theme-aware formatting, so applying a new theme
determines which fonts and colors are used by styles. That’s why you noticed a change in
the Cell Styles gallery after applying the new theme in the exercise. However, styles are
independent from themes in that you can change styles regardless of the theme that’s
applied to a document.

Take Note When you apply a heading cell style to text and then increase the font size
of that cell, the font size will not change after applying a new document theme. If you
don’t change the font size of heading text, apply a heading cell style, and then apply a
new theme, the heading text will display in the default font size for the new theme.

Applying Custom Color Formats


In the previous exercise, you used the Colors button on the Page Layout tab to apply a
different color scheme to the workbook. Each color scheme includes individual colors for
different worksheet elements that can be modified separately using the Create New
Theme Colors dialog box. This enables you to create custom color formats as needed in
your worksheets.

STEP BY STEP Apply Custom Color Formats


GET READY. LAUNCH Excel 2016 if it is not already open.
1. OPEN the 02 Music [Link] workbook from the data files for this lesson.
2. SAVE the workbook as 02 Music Sales [Link] in the lesson folder on your
flash drive.
3. Click the Page Layout tab, and then in the Themes group, click the Colors button.
4. Select Customize Colors at the bottom of the menu. The Create New Theme Colors
dialog box opens (Figure 2-17).

2 de 12 14/04/2021, 14:32
OneNote [Link]

Figure 2-17: The Create New Theme Colors dialog box


5. Click the arrow next to the Text/Background – Dark 1 color swatch and select
White, Text 1 in the top row, second column.
6. Next, click the arrow next to the Accent 3 color swatch and select Blue, Accent 1 in
the top row, fifth column.
7. In the Name box, type Music1 and then click Save. The adjusted colors now appear
on both worksheets of the workbook (Figure 2-18).

Figure 2-18: The workbook displays the modified color scheme


8. SAVE the workbook.
PAUSE. LEAVE the workbook open to use in the next exercise.

Take Note In addition to modifying color schemes using the Create New Theme Colors
dialog box, you can use the Colors dialog box to apply a specific custom color in your
worksheet. To do so, select the More Colors option from a color palette (such as the Fill
Color or Font Color palette). Select a color option on the Standard tab or click the
Custom tab and refine your color choice. The Custom tab also enables you to select
specific RGB or HSL values if you want to match a color exactly, such as a color in a
company logo.

Creating Custom Font Formats


In addition to customizing color schemes, you also can customize the font themes used
in a workbook. Excel provides dozens of font set choices, each consisting of a Heading
font and a Body font, which you can modify as needed for a custom look. You can choose
new theme fonts in your worksheets using the Create New Theme Fonts dialog box.

STEP BY STEP Create a Custom Font Format


GET READY. USE the 02 Music Sales [Link] workbook that is open from the
previous exercise.
1. On the Q1 Sales worksheet, merge and center the title in B2 over the range B2:F2.
Then, merge and center the title in B3 over the range B3:F3.
2. Click the Page Layout tab, and then in the Themes group, click the Fonts button.
Point to the various font sets in the Fonts gallery to display the preview in the
worksheet.
3. Point to and then select the Constantia-Franklin Gothic Book font set.
4. Click the Fonts button again and then select Customize Fonts at the bottom of the
menu. The Create New Theme Fonts dialog box opens (Figure 2-19).

3 de 12 14/04/2021, 14:32
OneNote [Link]

Figure 2-19: The Create New Theme Fonts dialog box


5. Click the Heading font drop-down arrow and select Bodoni MT Black in the font
list. The Sample in the dialog box adjusts to reflect the font change.
6. Click Save to save the changes to the theme fonts.
7. SAVE the workbook.
PAUSE. LEAVE the workbook open to use in the next exercise.

Creating and Modifying Cell Styles


Excel provides many cell styles on the Cell Styles gallery of the Home tab that make it
easy to apply fonts, fill colors, font styles, and borders with one click. If none of the
available options fit your needs, however, you can create a new cell style that can be
applied at any time in any workbook.

STEP BY STEP Create and Modify Cell Styles


GET READY. USE the 02 Music Sales [Link] workbook that is open from the
previous exercise.
1. On the Q1 Sales worksheet, click cell B5. You will start with the formatting that is
already applied to this cell, make some changes, and then create a custom cell style.
2. On the Home tab, in the Styles group, click the Cell Styles button and then click
New Cell Style near the bottom of the gallery. The Style dialog box opens.
3. In the Style name box, type MyStyle. Notice the existing styles applied to the style
in the Style Includes (By Example) list in the dialog box. You can select or deselect
check boxes to apply or remove any of these settings.
4. Click the Format button. In the Format Cells dialog box, click the Alignment tab,
click the Horizontal drop-down arrow, and select Center. Click the Font tab, and in
the Font style list, click Bold Italic. Click the Fill tab and select Dark Blue for the
Background Color.
5. Click OK. The changes you selected in step 4 appear in the Style dialog box (Figure
2-20). Click OK to close the Style dialog box.

Figure 2-20: Use the Style dialog box to create and modify custom cell styles
6. With B5 selected, click the Cell Styles button on the Home tab and select MyStyle
at the top of the gallery. Your new style is applied to cell B5.
7. After applying the cell style, you decide to remove the italic formatting from the
custom style. Click the Cell Styles button on the Home tab, right-click MyStyle at
the top of the gallery, and select Modify. The Style dialog box opens.

4 de 12 14/04/2021, 14:32
OneNote [Link]

8. Click the Format button. In the Format Cells dialog box, click the Font tab, and in
the Font style list, click Bold.
9. Click OK two times to close both dialog boxes. Cell B5 now displays the modified
style without italics.
10. SAVE the 02 Music Sales [Link] workbook and then CLOSE the workbook.
PAUSE. LEAVE Excel open for the next exercise.

Take Note When you create custom themes, color formats, font formats, and cell styles,
the custom settings display as a separate option at the top of the Themes, Colors, Fonts,
and Cell Styles galleries, respectively. You can use these galleries to apply the custom
settings to new areas of your workbook. If you want to delete a custom option, right-click
the option in the applicable gallery and click Delete.

Recording and Modifying a Basic Macro


A basic macro is a recording of a sequence of commands and typed entries that you can
then replay elsewhere in the worksheet. Macros enable you to perform the same
sequences of commands in different places, cutting down the time it takes to complete
redundant work.
There are ways to automate the formatting of cells that are actually easier than recording
and playing back macros. The types of steps you typically want to record are the
repetitious kind that you would otherwise have to repeat yourself dozens of times or
more.

Take Note Excel records only those steps that have a direct impact on the contents of
the worksheet. To be accurate, it records the impact those steps have, not the actual
commands that led to the impact. For example, if you select several rows and columns,
Excel records the act of the rows and columns being grouped. But if you expand or
collapse that group, it does not record that action because doing so does not impact the
worksheet itself. Exceptions include filtering and sorting ranges and tables, which Excel
does record.

STEP BY STEP Record and Modify a Basic Macro


GET READY. LAUNCH Excel if it is not already open.
1. OPEN the 02 [Link] workbook from the data files for this lesson. If the
Developer tab is already displayed on the Ribbon, skip to step 5.
2. Click the File tab and then click Options.
3. In the Excel Options dialog box, click Customize Ribbon.
4. In the Main Tabs list on the right, select the Developer check box. This adds the
Developer tab to the Excel Ribbon, enabling you to more easily record macros. Click
OK.
5. The macro that you will record creates a custom subtotal row at the place you
define, rather than at some place Excel determines. The rule you follow is that the
user (you) must select the cell where you want the subtotal to appear, and then run
the macro. So to prepare for macro recording, click cell D20.
6. Click the Developer tab, and then in the Code group, find Use Relative References.
If it is not highlighted, click to select it. You want relative references for this macro.
7. In the Code group, click Record Macro.
8. In the Record Macro dialog box, click the Macro name box and replace the existing
text with CustomSubtotals.
9. In the Shortcut key box beside Ctrl+, type the capital S. This changes the shortcut
key to Ctrl+Shift+S. Leave Store macro in set to This Workbook. In the Description
box, type Creates custom subtotal rows. The Record Macro dialog box should now
appear as shown in Figure 2-21.

5 de 12 14/04/2021, 14:32
OneNote [Link]

Figure 2-21: The Record Macro dialog box


10. Click OK. You are now recording a macro.

Troubleshooting If you make a mistake during the macro recording, don’t worry.
Click Stop Recording in the Code group of the Developer tab. Then start again from
step 7. Use the same name, and when Excel asks whether you want to overwrite the
existing macro with the same name, respond with Yes.

11. Press Shift+Down Arrow.


12. Click the Home tab, and then in the Cells group, click the Insert drop-down arrow.
In the menu, click Insert Sheet Rows.
13. Press Shift+Up Arrow.
14. In the Editing group, click AutoSum. Do not press Enter.
15. In the Clipboard group, click Copy.
16. Press Tab.
17. Type the partial formula =max(.
18. In the Clipboard group, click Paste.
19. Type ) (end parenthesis) and then press Tab.
20. Press Left Arrow.
21. Click the Font Color drop-down arrow and select Blue-Gray, Text 2 (first row,
fourth column under Theme Colors).
22. Click the Italic button.
23. Click the Developer tab, and then in the Code group, click Stop Recording.
As Figure 2-22 shows, the macro generates a total for the bottom of the arbitrary
cluster of records, and also tabulates the highest (maximum) value in that cluster in
the cell adjacent to the subtotal.

Figure 2-22: Custom subtotal generated by the macro


24. On the Developer tab, in the Code group, click Visual Basic. You will make a simple
edit to the macro code that doesn’t require knowledge of VBA.
25. In the upper-left pane of the Microsoft Visual Basic for Applications window, expand
the Modules folder, if necessary (click the + sign). Then, double-click Module1. The
macro code displays in the Code window on the right.
26. In the Code window, locate the code line that reads “[Link] = True”
near the end of the code listing. Drag over the text Italic and type Bold in its place.

6 de 12 14/04/2021, 14:32
OneNote [Link]

Be careful not to make any other changes to the code. Your screen should appear
similar to Figure 2-23.

Figure 2-23: Modifying the CustomSubtotals macro in the Visual Basic for
Applications window
27. In the menu bar at the top of the window, click File and then select Close and
Return to Microsoft Excel.
28. In the worksheet, delete rows 20 and 21. You will test the macro using the assigned
shortcut key and ensure that the macro modification works correctly.
29. Select cell D20 and then press Ctrl+Shift+S. The macro runs and the result in cell
E20 appears in bold rather than italic formatting.
30. Click the File tab and then click Save As. Select a folder or click Browse to navigate
to the folder where you are saving your files.
31. In the Save As dialog box, under Save as type, choose Excel Macro-Enabled
Workbook (*.xlsm). Save the workbook as 02 Revenues [Link] in the
lesson folder on your flash drive. Click OK if a message box displays after you save
the file.
PAUSE. LEAVE the workbook open to use in the next exercise.

Take Note For security reasons, Excel no longer saves macros in its regular .XLS and
.XLSX file formats. Now, the only way to save a macro-enabled workbook is to give it the
special .XLSM file type. This way, companies that want to avoid any possibility of
spreading malware can enforce policies preventing .XLSM files from being attached to or
received within e-mails.

Because of the proliferation of malicious software, Microsoft has set up Excel so that after
it’s installed, you cannot execute macros from a file you open (even an explicitly macro-
enabled workbook) until you read the notification and click Enable Content. If you never
plan to run macros or if you’re skeptical about any of your office colleagues, you can turn
off macros completely. You can also turn off the notifications and enable all macros, if
you work in an office such as a financial services provider where macros are in use
constantly, you trust the source of the Excel workbooks, and notifications would only get
in the way.

STEP BY STEP Manage Macro Security


GET READY. USE the 02 Revenues [Link] workbook that is open from the
previous exercise.
1. On the Developer tab, in the Code group, click Macro Security.
2. In the Trust Center dialog box, click Disable all macros with notification to have
Excel warn you whenever an opened workbook contains macros, enabling you to
turn those macros on or off based on your decision. This is the recommended
setting for most situations (Figure 2-24).

7 de 12 14/04/2021, 14:32
OneNote [Link]

Figure 2-24: The Trust Center dialog box


3. Click OK.
4. SAVE the 02 Revenues [Link] workbook (click OK if a message box
displays) and then CLOSE the workbook.
PAUSE. LEAVE Excel open for the next exercise.

Inserting Form Controls


If you are developing a workbook that other people are going to use—either for data
input or to view a report—you might find it helpful to your workbook’s users if you can
add controls such as check boxes, command buttons, and spin buttons. Adding controls
to a workbook helps to limit a user’s choices or to make the available choices easier to
select.
Excel offers two families of controls: Form controls and ActiveX controls. Form controls
are native to Excel and are backward compatible to Excel 95. ActiveX controls are used in
a variety of applications besides Excel, and can be controlled via VBA. You can add VBA to
your workbook to respond to events. ActiveX controls also have more options or
properties you can control.

Take Note Try using a Form control first. If you find that you need a property that the
Form control cannot offer, try the ActiveX version. Note that many of the ActiveX controls
on the Developer tab’s Insert menu are from the MS Forms library. That library is external
to Excel and must be loaded. This is one of the fundamental differences between the
Form controls, which are built in to Excel, and any ActiveX controls.

Both types of controls offer the ability to link input (populate a list) and output (show
what was selected) between the control and a worksheet cell.
Note that both Form controls and ActiveX controls float on the worksheet. This means
that like shapes, you can tell Excel whether you want to move and/or resize your controls
as you insert, delete, or resize rows and columns.
A basic listing of the available form controls includes the following:

Control Forms Active Description


X
Button / ✔ ✔ Used to run a macro in the workbook.
Command
Button
Check Box ✔ ✔ TRUE/FALSE
Combo Box ✔ ✔ Used to select an option from a list; uses a drop-down
button to hide the list until the button is clicked. Note
that with an ActiveX combo box, you can pick from the
list or type in any value you want. With a Form control,
you can only pick from the list.
Group Box ✔ Allows you to group Form controls. Most often used to
group option buttons in cases where you have more
than one group of option buttons on the worksheet.
Image ✔ Image controls are usually used for fairly sophisticated
solutions that involve VBA. If all you need is a picture,
you can simply insert a picture from the Insert tab. You

8 de 12 14/04/2021, 14:32
OneNote [Link]

don’t need an ActiveX image control. Given that you


can assign a macro to a picture object, ActiveX picture
controls tend to be the best option in a fairly narrow
and sophisticated solution band.
Label ✔ ✔ Just a label you don’t input any values with it.
List Box ✔ ✔ Similar to a combo box but shows several options at
once. In the case of the ActiveX control, you cannot
type in a value that is not on the list (which you can do
with a combo box).
Option ✔ ✔ Used to pick from mutually exclusive options. If you
Button pick Option A, then Options B and C are deselected
(changed to FALSE).
Scroll Bar ✔ ✔ Similar to a spin button, except you have a slider
control that allows users to make large changes to the
control’s value very quickly.
Spin Button ✔ ✔ Allows you to increment/decrement a number.
Text Box ✔ Type in any value. Not available as a Form control.
Toggle Button ✔ TRUE/FALSE—similar to a check box, but has a Triple
State option that allows a third #N/A option.

STEP BY STEP Insert Form Controls


GET READY. LAUNCH Excel if it is not already open.
1. OPEN the 02 [Link] workbook from the data files for this lesson.
2. SAVE the workbook as 02 Controls [Link] in the lesson folder on your flash
drive.
3. Click the Developer tab. In the Controls group, click the Insert button. Select the
ActiveX Combo Box control.
4. Place the mouse pointer close to the top-left corner of cell E4. Before you click the
mouse, press the Alt key. Then click the mouse and drag the pointer just above and
to the left of the bottom-right corner of cell E4. Release the mouse button first, then
release the Alt key.
5. Click the Combo Box control you just inserted into E4 to select it, if necessary. If the
six circular resizing handles are not displayed around the borders of the control,
then click the Design Mode button on the Developer tab.
6. Next to the Design Mode button on the Ribbon is the Properties button. Click the
Properties button. The Properties window opens.
7. For the LinkedCell property, in the second column, type G4.
8. For the ListFillRange property, type B3:B21.
9. Change the ListRows property to 12. Compare your settings in the Properties
window with Figure 2-25.

9 de 12 14/04/2021, 14:32
OneNote [Link]

Figure 2-25: Modifying properties for a combo box ActiveX control


10. Close the Properties window and then click any cell on the worksheet.
11. Click the Design Mode toggle button to turn off Design Mode. Click the drop-
down arrow in cell E4 and select various values. The value displayed in cell G4
should match your selection.
12. Try typing Taupe into the control and then press Enter. Excel should accept the
entry and display Taupe in cell G4.
13. Select cells B3:B21. In the Name Box on the left end of the formula bar, enter the
name [Link] and then press Enter (note that the first character in the name is a
lowercase “L” not the number 1).
14. Use the process in step 13 to assign the following names to the indicated cells
below (again, note that the first character in each name is a lowercase “L” not the
number 1):

K6 [Link].F
G6 [Link].X
K4 [Link].F
K8 [Link].F
G11 [Link].X
G23 lnk.Option1.X
G25 lnk.Option2.X
G27 lnk.Option3.X
K20 [Link].F
G8 [Link].X
15. On the Developer tab, in the Controls group, click Insert and then select the
ActiveX Check Box control.
16. Place the mouse pointer close to the top-left corner of cell E6. Before you click the
mouse, press the Alt key. Then click the mouse and drag the pointer just above and
to the left of the bottom-right corner of cell E6. Release the mouse button first and
then release the Alt key.
17. Click the Check Box control you just inserted into E6 to select it, if necessary. If the
six white circular resizing handles are not displayed around the borders of the
control, then click the Design Mode button on the Developer tab.
18. Click the Properties button.
a. For the Caption property, type Matte Finish?.
b. For the LinkedCell property, type [Link].X.
19. Turn off Design Mode and test the check box control.
20. Repeat previous instructions as appropriate to add the following controls:
a. An ActiveX Text Box control in E8 with a LinkedCell property of
[Link].X
b. An ActiveX List Box control in E11:E21, LinkedCell property is [Link].X
and the ListFillRange is [Link]
c. An ActiveX Option Button control in E23, LinkedCell property is
lnk.Option1.X and the Caption is Matte Finish
d. An ActiveX Option Button control in E25, LinkedCell property is
lnk.Option2.X and the Caption is Glossy Finish
e. An ActiveX Option Button control in E27, LinkedCell property is
lnk.Option3.X and the Caption is No Finish
21. Close the Properties window, turn off Design Mode, and test your controls.
22. On the Developer tab, click the Insert button. This time insert a Form control
Combo Box into cell I4.
23. Right-click the combo box control and select Format Control from the shortcut
menu. Select the Control tab.

10 de 12 14/04/2021, 14:32
OneNote [Link]

24. Set the Input range to [Link] and the Cell link to [Link].F and then
click OK.
25. Click any regular cell. If the pointer changes into a pointing finger when you mouse
over the control in cell I4, then you can use it.
26. Try typing Taupe into the Forms combo box in cell I4. Unlike the ActiveX combo
box, you can’t type into a Forms combo box.
27. Place a Form control check box in I6.
28. Right-click the check box and select Format Control.
29. On the Control tab, set the Cell link to [Link].F.
30. Click the Alt Text tab and change the alternative text to Matte Finish?. Click OK.
31. Click in cell H6 then press the right arrow key once. Then press Delete. This will
clear out the text in I6 so you can read the check box better.
32. Notice that changing the Alt Text in step 30 didn’t change the check box’s caption.
Right-click the check box control and select Edit Text to change the caption to
Matte Finish?.
33. Place a Form control list box across cells I8:I18. (Remember, if you press the Alt
key prior to starting your drag, the control will snap to the cell borders.)
34. Right-click the list box and select Format Control from the shortcut menu. Click
the Control tab and make the following entries:
a. Input range: [Link]
b. Cell link: [Link].F
35. Click OK and then select any cell in the worksheet. Test your Forms list box control.
36. Delete the text in cells I20, I22 and I24.
37. Place a Form control Option Button in cell I20 and edit the text to read Matte
Finish.
38. Place a Form control Option Button in cell I22 and edit the text to read Glossy
Finish.
39. Place a Form control Option Button in cell I24 and edit the text to read No Finish.
40. Right-click any of the Option Button controls and select Format Control. Click the
Control tab, set the Cell link to [Link].F, and then click OK. Your worksheet
should now look similar to Figure 2-26.

Figure 2-26: Inserting Form controls and ActiveX controls


41. Play with the controls a bit and notice that the ActiveX combo box and list box
controls are returning the text you select. Compare this to the Form combo box and
list box. Both of those return the index (position) of your choice in the list of
choices.
42. SAVE the 02 Controls [Link] workbook and then CLOSE the workbook.
PAUSE. LEAVE Excel open for the next exercise.

Take Note If you accidentally double-clicked any of the ActiveX controls in the process
of inserting them, depending on the type of control, Excel will automatically insert either

11 de 12 14/04/2021, 14:32
OneNote [Link]

a stub _Click Event Handler procedure or a stub _Change Event Handler procedure into
the code (class) module for the worksheet. You may have just closed the VBE or switched
back to Excel without really noticing that this happened. If you did this, then you’ll get a
message from Excel telling you that a VB project cannot be saved in a macro-free
workbook. Just click Yes to go ahead and save the workbook. The auto-generated event-
handler stub will automatically be discarded.

Note that in the case of option button controls, all three Form control option buttons
have the same linked cell and this linked cell contains the index of whichever option
button is selected. Compare that to the ActiveX option buttons where each option button
has its own linked cell and each linked cell toggles between TRUE and FALSE.

12 de 12 14/04/2021, 14:32

You might also like