Download presentation
Presentation is loading. Please wait.
Published byWillis Melvyn Lindsey Modified over 6 years ago
1
Exploring Microsoft® Excel® 2016 Series Editor Mary Anne Poatsy
Exploring Microsoft Office 2016 Series Editor Mary Anne Poatsy Mulbery|Davidson Series Created by Dr. Robert T. Grauer
2
Copyright © 2017 Pearson Education, Inc.
Chapter 12 In Chapter 12, you will learn how to design templates, edit styles, and create macros. Templates, Styles, and Macros Standardizing Workbooks Copyright © 2017 Pearson Education, Inc.
3
Copyright © 2017 Pearson Education, Inc.
Objectives Select a Template Apply Themes and Backgrounds Apply Cell Styles Create and Use a Template Protect a Cell, a Worksheet, and a Workbook The objectives for this chapter are: Select a Template Apply Themes and Backgrounds Apply Cell Styles Create and Use a Template Protect a Cell, a Worksheet, and a Workbook Additional objectives are listed on the next slide. Copyright © 2017 Pearson Education, Inc.
4
Copyright © 2017 Pearson Education, Inc.
Objectives Create a Macro Create Macro Buttons Set Macro Security Create a Sub Procedure Create a Custom Function The objectives for this chapter are: Create a Macro Create Macro Buttons Set Macro Security Create a Sub Procedure Create a Custom Function Copyright © 2017 Pearson Education, Inc.
5
Objective 1: Select a Template
In this section, the skills include: Select a Template Skills: Select a Template Copyright © 2017 Pearson Education, Inc.
6
Select a Template Search for online templates Templates on computer
A template is a partially completed document that you use as a model to create other documents that have the same structure and purpose. A template typically contains standard labels, formulas, and formatting but may contain little or no quantitative data. To create a new file based on a template: Start Excel, or if you are already working within a workbook, click the File tab and click New. Backstage view displays a gallery of featured templates. Select a template from templates you have recently used, sample templates that were installed with the software, or download new templates. Click Create to load the template data as a new workbook. Templates on computer Copyright © 2017 Pearson Education, Inc.
7
Objective 2: Apply Themes and Backgrounds
In this section, the skills include: Customize a Theme Apply a Background Skills: Customize a Theme Apply a Background Copyright © 2017 Pearson Education, Inc.
8
Apply Themes and Backgrounds
Click Themes Page Layout tab Themes gallery Besides using a template, you might want to apply a theme or insert a background to create a consistent look with the workbooks you create. A theme is a collection of formats that include coordinated colors, fonts, and special effects to provide a consistent appearance. To apply a theme to all worksheets in a workbook: On the Page Layout tab in the Themes group, click Themes to display the Themes gallery. Click a theme to make it active. Copyright © 2017 Pearson Education, Inc.
9
Apply Themes and Backgrounds
Colors Fonts Effects After applying a theme, you can customize the three elements that comprise the theme: colors, fonts, and effects. The Themes group on the Page Layout tab contains commands to customize the theme. Clicking any one of these will display a gallery of choices. Copyright © 2017 Pearson Education, Inc.
10
Apply Themes and Backgrounds
Excel enables you to use graphics as the background of a worksheet. A background is an image placed behind the worksheet data. To add a background to a worksheet: On the Page Layout tab in the Page Setup group, click Background to display the Insert Pictures dialog box. Select From a file and then select the picture file to be used as a background. Click Insert. As seen in the slide, the image, like a background image on a web page, is tiled across your worksheet. Note: The background image displays only in the worksheet onscreen; it does not print. Copyright © 2017 Pearson Education, Inc.
11
Objective 3: Apply Cell Styles
In this section, the skills include: Create Custom Cell Styles Modify and Remove Cell Styles Skills: Create Custom Cell Styles Modify and Remove Cell Styles Copyright © 2017 Pearson Education, Inc.
12
Copyright © 2017 Pearson Education, Inc.
Apply Cell Styles Cell style—collection of format settings based on the currently selected theme Cell styles control: Font attributes Borders and fill styles and colors Vertical and horizontal cell alignment Number formatting Cell-protection settings A cell style is a collection of format settings based on the currently selected theme that provides a consistent appearance within a worksheet and among similar workbooks. Cell styles control the following formats: • Font attributes, such as font and font size • Borders and fill styles and colors • Vertical and horizontal cell alignment • Number formatting, such as currency and number of decimal places • Cell-protection settings Copyright © 2017 Pearson Education, Inc.
13
Copyright © 2017 Pearson Education, Inc.
Apply Cell Styles Cell categories To apply a style to a cell or range of cells: On the Home tab under Styles in the Styles group, click Cell to display the Cell Styles gallery. Click a style to apply it to the active cell or range. As seen in the slide, the gallery contains the following five predefined cell categories: • Good, Bad, and Neutral • Data and Model • Titles and Headings • Themed Cell Styles • Number Format Copyright © 2017 Pearson Education, Inc.
14
Copyright © 2017 Pearson Education, Inc.
Apply Cell Styles Cell Styles Name style You can create your own custom cell styles if the predefined cell styles do not meet your needs. To create a custom cell style: Click the cell that contains the desired formatting. On the Home tab in the Styles group, click Cell Styles. Select New Cell Style at the bottom of the gallery to open the Style dialog box. Type the name for your new style in the Style name box. Click the check boxes to select the style options you want in the Style Includes (By Example) section. Click OK to close the Style dialog box. After you create and apply cell styles to a worksheet, you might decide to change the format of a style. To modify a style: Right-click the style in the Cell Styles gallery. Select Modify to open the Style dialog box. Make the desired format changes and click OK. Select options Copyright © 2017 Pearson Education, Inc.
15
Objective 4: Create and Use a Template
In this section, the skills include: Create and Use a Template Skills: Create and Use a Template Copyright © 2017 Pearson Education, Inc.
16
Create and Use a Template
Template creation guidelines: • Use formatted, descriptive labels, empty cells, and formulas • Avoid values when possible in formulas • Use appropriate error trapping functions • Include data-validation settings • Include template instructions • Turn off worksheet gridlines • Apply appropriate template formatting • Give worksheets meaningful names When creating a template from scratch, adhere to the following guidelines: • Use formatted, descriptive labels, empty cells, and formulas. • Avoid values when possible in formulas; use cell references instead. • Use an appropriate function to trap errors. • Include data-validation settings (valid data rules, warning messages, input messages). • Include instructions for the template. • Turn off worksheet gridlines, if desired, for clarity. • Apply appropriate formatting to the template. • Give worksheets meaningful names and delete worksheets that are not used. Copyright © 2017 Pearson Education, Inc.
17
Create and Use a Template
Select Template To save a workbook as a template: Click the File tab and click Export. Click Change File Type. Click Template in the Change File Type list and click Save As to display the Save As dialog box. Select the desired location, type a name in the File name box, and then click Save. To save the template so that it automatically is included in the Templates gallery: Click Save As in Backstage view, click Save As, and then click This PC to open the Save As dialog box. Click the Save as type arrow and select Excel Template. Type a name in the File name box and click Save. Copyright © 2017 Pearson Education, Inc.
18
Objective 5: Protect a Cell, a Worksheet, and a Workbook
In this section, the skills include: Lock and Unlock Cells Protect a Worksheet Protect a Workbook Skills: Lock and Unlock Cells Protect a Worksheet Protect a Workbook Copyright © 2017 Pearson Education, Inc.
19
Protect a Cell, a Worksheet, and a Workbook
Click Format Selected cell Lock cell Most templates protect worksheets by enabling users to change only particular cells in a worksheet. For example, users are permitted to enter data in input cells, but they cannot change formulas or alter formatting or worksheet structure. A locked cell is one that prevents users from editing the contents or formatting of that cell in a protected worksheet. By default, all cells in a workbook are locked. To unlock input cells: Select the cells in which you want users to be able to enter or edit data. On the Home tab in the Cells group, click Format. Select Lock Cell in the Protection section to unlock the active cell or selected range of cells. Copyright © 2017 Pearson Education, Inc.
20
Protect a Cell, a Worksheet, and a Workbook
Enter password Confirm password After unlocking cells that users can modify, you are ready to protect the worksheet. When a worksheet is protected, users can be prevented from altering the locked cells. During the process of protecting a worksheet, a password can be used to ensure that only those who know the password can unprotect the worksheet. To protect a worksheet: On the Home tab in the Cells group, click Format. Select Protect Sheet in the Protection section to display the Protect Sheet dialog box. Select the check boxes for actions you want users to be able to do in the Allow all users of this worksheet to list. Type and confirm a password in the Password to unprotect sheet box. Read the caution statement and click OK. To unprotect a worksheet: On the Home tab in the Cells group, click Format and select Unprotect Sheet to display the Unprotect Sheet dialog box. Type the password in the Password box and click OK. Select actions Copyright © 2017 Pearson Education, Inc.
21
Protect a Cell, a Worksheet, and a Workbook
Click Protect Workbook Select action You can prevent users from inserting, deleting, renaming, moving, copying, and hiding worksheets within the workbook by protecting the entire workbook with a password. To protect a workbook: On the Review tab in the Changes group, click Protect Workbook to display the Protect Structure and Windows dialog box. Click the check boxes for the desired action in the Protect workbook for section. Type and confirm a password in the Password (optional) box. To save a workbook as a template, you: Click the File tab, click Save As, click This PC, and then click Browse. Select Excel Template from the Save as type menu and click Save. Enter password Copyright © 2017 Pearson Education, Inc.
22
Objective 6: Create a Macro
In this section, the skills include: Use the Macro Recorder Record a Macro Use Relative References Run a Macro Skills: Use the Macro Recorder Record a Macro Use Relative References Run a Macro Copyright © 2017 Pearson Education, Inc.
23
Copyright © 2017 Pearson Education, Inc.
Create a Macro Developer tab Developer tab A macro is a set of instructions that executes a sequence of commands to automate repetitive or routine tasks. You can either use the Macro Recorder or type instructions using Visual Basic for Applications (VBA), which is a programming language that can be used within various software packages to enhance and automate functionality. The Macro Recorder records your commands, keystrokes, and mouse clicks and stores Excel commands as VBA code within a workbook. To use the macro record, you must first install it on the Ribbon. To display the Developer tab on the Ribbon: Click the File tab and click Options to open the Excel Options dialog box. Click Customize Ribbon to display the Customize the Ribbon options. Click the Developer check box in the Main Tabs list to select it and click OK. The slide shows that the Developer tab has been added. Take some time to familiarize yourself with the groups and buttons on this tab. Note: The Record Macro button, which we will discuss on the next slide. Copyright © 2017 Pearson Education, Inc.
24
Create a Macro Name the macro Select shortcut key
Recording a macro is straightforward: You initiate the macro recording, perform a series of commands as you normally do, then stop the macro recording. To record a macro: On the Developer tab in the Code group, click Record Macro to display the Record Macro dialog box. Type a meaningful name for the macro in the Macro name box. Assign a keyboard shortcut, if desired, for your macro in the Shortcut key box. Click the Store macro in arrow and select a storage location. Type a description of the macro and its purpose in the Description box and click OK to start recording the macro. Perform the commands that you want to record. Click Stop Recording on the Developer tab. Specify storage location Copyright © 2017 Pearson Education, Inc.
25
Copyright © 2017 Pearson Education, Inc.
Create a Macro Select macro Run the macro It is important to determine if your macro should use relative, absolute, or mixed references as you record the macro. By default, when you select cells when recording a macro, the macro records the cells as absolute references. If you want flexibility in that commands are performed relative to the active cell when you run the macro, click the Macros arrow in the Macros group on the View tab and select Use Relative References before you perform the commands. To run a macro: Select the location where you will test the macro. On the Developer tab in the Code group, click Macros to display the Macro dialog. Select the macro from the Macro name list and click Run. As seen in the slide, the ClearForm macro will be run. Because the macro was named with a meaningful name, we know that it will clear the contents of a form. Copyright © 2017 Pearson Education, Inc.
26
Objective 7: Create Macro Buttons
In this section, the skills include: Create Macro Buttons Skills: Create Macro Buttons Copyright © 2017 Pearson Education, Inc.
27
Copyright © 2017 Pearson Education, Inc.
Create Macro Buttons The simplest way to access frequently used macros within a workbook is to assign a macro to a button on a worksheet. That way, when you or other people use the workbook, it is easy to click the button to run the macro. To add a macro button to a worksheet: On the Developer tab in the Controls group, click Insert, and then click Button (Form Control) in the Form Controls section of the Insert gallery. Drag the crosshair pointer to draw the button on the worksheet. When you release the mouse button, the Assign Macro dialog box is displayed. Select the macro to assign to the button and click OK. Right-click the button, select Edit Text and type a more descriptive name for the button. Click the worksheet to complete the button. Click the cell that should be the active cell when the macro runs and click the button to execute the macro assigned to the button. Button Name macro Copyright © 2017 Pearson Education, Inc.
28
Copyright © 2017 Pearson Education, Inc.
Create Macro Buttons In this slide, we see that the ClearForm macro has been assigned to the button Clear Form and positioned on the worksheet below the form. Clear Form button Copyright © 2017 Pearson Education, Inc.
29
Objective 8: Set Macro Security
In this section, the skills include: Set Macro Security Skills: Set Macro Security Copyright © 2017 Pearson Education, Inc.
30
Copyright © 2017 Pearson Education, Inc.
Set Macro Security Security warning Enable Content Macro security is a concern for anyone who uses files containing macros. A macro virus is code written in VBA set to perform malicious actions when run. By default, Excel automatically disables the macros and displays a security warning that macros have been disabled. Click Enable Content to use the workbook and run macros. Macro button Copyright © 2017 Pearson Education, Inc.
31
Set Macro Security Select a security setting
You can use the Trust Center dialog box to change settings to make it easier to work with macros. The 12 Trust Center options are described in the Table 12.1 in the textbook. To open the Trust Center: Click the File tab and click Options. Click Trust Center in the Excel Options dialog box. Click Trust Center Settings to display the Trust Center dialog box and select the desired option. Copyright © 2017 Pearson Education, Inc.
32
Objective 9: Create a Sub Procedure
In this section, the skills include: Create a Sub Procedure Use VBA with a Protected Worksheet Edit a Macro in the Visual Basic Editor Skills: Create a Sub Procedure Use VBA with a Protected Worksheet Edit a Macro in the Visual Basic Editor Copyright © 2017 Pearson Education, Inc.
33
Copyright © 2017 Pearson Education, Inc.
Create a Sub Procedure Project Explorer pane Comments Visual Basic Editor Commands performed while recording a macro are translated into Visual Basic for Applications (VBA) code. A module is a container in which VBA code is stored. The Visual Basic Editor is an application used to create, edit, execute, and debug Office application macros using programming code. A sub procedure, which is also created when using the Macro Recorder, performs an action on a workbook but does not return specific values. An example of a sub procedure is ClearForm, which we have been discussing in this chapter. The first step to creating a sub procedure is inserting a new module or editing data in an existing module within the VBA Editor. To access the VBA Editor, press Alt + F11. The left side of the VBA window contains the Project Explorer and Visual Basic statements appear in the Text Editor window on the right side. Code Copyright © 2017 Pearson Education, Inc.
34
Copyright © 2017 Pearson Education, Inc.
Create a Sub Procedure As an example of a procedure, which is a named sequence of statements stored in a macro, consider the creation of a sub procedure that enters a date into a cell. To create a basic sub procedure that would enter a date into a cell, you: Open the VBA Editor and select Module from the Insert menu. Type Sub CurrentDate() and press Enter. Type ' and add a descriptive comment. Type range("H7") = date and press Enter. Save and exit the Visual Basic Editor. Copyright © 2017 Pearson Education, Inc.
35
Copyright © 2017 Pearson Education, Inc.
Create a Sub Procedure A run-time error is a software or hardware problem that prevents a program from working correctly while executing a program. This can happen when attempting to alter a locked cell. We are going to modify the code from the previous slide to allow the font in cell H7 to be italicized. To do this, we need to disable protection, make the font change, and then enable protection. The syntax may seem strange, but look at the code to get a basic understanding of what is happening. Copyright © 2017 Pearson Education, Inc.
36
Copyright © 2017 Pearson Education, Inc.
Create a Sub Procedure You can edit an existing macro using the Visual Basic Editor. Select it from the Project Explorer pane to display the code in the Visual Basic Editor. Without any explanation given, study the code and see if you can figure out what is being done in this macro. Copyright © 2017 Pearson Education, Inc.
37
Objective 10: Create a Custom Function
In this section, the skills include: Create a Custom Function Skills: Create a Custom Function Copyright © 2017 Pearson Education, Inc.
38
Create a Custom Function
There are several hundred built-in functions in Excel that can perform tasks as simple as capitalizing the first letter of a word, such as the Proper function, or as complex as a multi-conditional sum created with SumIFs. If none of the numerous built-in functions meet your needs, you can create your own custom function using VBA. The fundamental difference between a procedure is that a procedure performs some kind of action, where as a function returns a value. When creating a custom function in VBA, you start by creating a new module and typing FUNCTION followed by the name of the function you are creating and the arguments that the function will use inside parentheses. Once again, look at the code and see if you can figure out what it does, and what the function returns as an answer. The choice of meaningful names makes it a little easier to figure out what is happening. Copyright © 2017 Pearson Education, Inc.
39
Copyright © 2017 Pearson Education, Inc.
Summary Achieving a unified look: Selecting a template Customizing a theme Protect a spreadsheet: Cell level Worksheet level Workbook level Create, edit, and run macros: Macro Recorder Visual Basic Editor Sub procedure Function In this chapter, we learned how to apply templates, themes, and styles to achieve a unified look, how to protect a workbook, and how to create and edit macros. Achieving a unified look by: Selecting a template from your computer or online Customizing a theme to meet your needs Protect a spreadsheet: On the cell level On the worksheet level On the workbook level Create, edit, and run macros: Using Macro Recorder Using Visual Basic Editor Sub procedure to perform an action Function to return a value Copyright © 2017 Pearson Education, Inc.
40
Copyright © 2017 Pearson Education, Inc.
Questions ? It is important that you know how to design templates, edit styles, and create macros. Are there any questions? Copyright © 2017 Pearson Education, Inc.
41
Copyright Copyright © 2017 Pearson Education, Inc.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.