Using Macros and Visual Basic for Applications (VBA) with Excel

Slides:



Advertisements
Similar presentations
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Excel Project 4 Financial Functions, Data Tables, Amortization Schedules, and Hyperlinks.
Advertisements

Creating Templates and Working with Multiple Worksheets and Workbooks
Chapter 3 Creating a Business Letter with a Letterhead and Table
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Chapter 4 Financial Functions, Data Tables, and Amortization Schedules
Developing an Excel Application
Tutorial 8: Developing an Excel Application
Microsoft Office 2007 Excel Chapter 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
1 Excel Lesson 1 Understanding Excel Fundamentals Microsoft Office 2010 Fundamentals Story / Walls.
Chapter 5 Multitable Forms
Chapter 1 Creating a Flyer
Using a Template to Create a Resume and Sharing a Finished Document
Chapter 5 Creating, Sorting, and Querying a Table
Microsoft Excel 2010 Chapter 7
Chapter 1 Databases and Database Objects: An Introduction
Copyright 2007, Paradigm Publishing Inc. POWERPOINT 2007 CHAPTER 1 BACKNEXTEND 1-1 LINKS TO OBJECTIVES Create Presentation Open, Save, Run, Print, Close,Delete.
Microsoft Office 2007 Excel Chapter 9 Part 3: Creating and Formatting Pivot Charts and PivotTables.
Creating, Formatting, and Editing a Word Document with a Picture
Microsoft Excel 2010 Chapter 8
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Macros in Excel Intro to lab 1. Macroinstructions Macro is recorded in VBA module sequence of Excel operations Macros can automate tasks in Excel Macro.
Excel Lesson 14 Creating and Using Macros Microsoft Office 2010 Advanced Cable / Morrison 1.
Spreadsheet. Objectives Create a new blank workbook. Create a new blank workbook. Identify user interface elements that you can use to accomplish basic.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Office Word 2013 Core Microsoft Office Word 2013 Core Courseware # 3250 Lesson 8: Using Productivity Tools.
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 3 Maintaining a Database
DEVELOPING A PROFESSIONAL LOOKING WORKSHEET By Dr. Ennis - Cole.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Chapter 1 Databases and Database Objects: An Introduction
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
INSERT BOOK COVER 1Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Office Excel 2010 by Robert Grauer, Keith.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Excel Project 6 Creating Templates and Working with Multiple Worksheets and Workbooks.
Microsoft Publisher 2010 Chapter 7 Advanced Formatting and Merging Publications with Data.
Chapter 1 Creating a Worksheet and a Chart
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Microsoft Publisher 2010 Chapter 1 Creating a Flyer.
Chapter 4 Working with Information Graphics
Microsoft Access 2010 Chapter 4 Creating Reports and Forms.
Microsoft Office 2007 Excel Chapter 1 Creating a Worksheet and an Embedded Chart.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Microsoft Office 2010 is the newest version of Microsoft Office, offering features that provide users with better functionality and easier ways to work.
Microsoft Excel 2010 Chapter 2 Formulas, Functions, and Formatting.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 11 Collaboration Features for Workbooks Microsoft Excel 2013.
Chapter 5 Working with Multiple Worksheets and Workbooks Microsoft Excel 2013.
Chapter 10 Using Macros, Controls and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2013.
Chapter 4 Financial Functions, Data Tables, and Amortization Schedules Microsoft Excel 2013.
PowerPoint Chapter 1 Creating and Editing a Presentation with Clip Art Discovering Computers & Microsoft Office 2010.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
Excel Chapter 1 Creating a Worksheet and an Embedded Chart
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Chapter 8 Working with Trendlines, PivotTable Reports, PivotChart Reports, and Slicers Microsoft Excel 2013.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Excel Tutorial 8 Developing an Excel Application
Chapter 7 Advanced Form Techniques
Exploring Microsoft® Excel® 2016 Series Editor Mary Anne Poatsy
Chapter 1 Creating a Worksheet and an Embedded Chart
Chapter 1 Databases and Database Objects: An Introduction
Objectives At the end of this session, students will be able to:
Microsoft Excel 2007 – Level 2
Presentation transcript:

Using Macros and Visual Basic for Applications (VBA) with Excel Microsoft Excel 2010 Chapter 10 Using Macros and Visual Basic for Applications (VBA) with Excel

Objectives Use passwords to assign protected and unprotected status to a worksheet Use the macro recorder to create a macro Execute a macro and view and print code for a macro Customize the Quick Access Toolbar by adding a button Understand Visual Basic for Applications (VBA) code and explain event-driven programs Using Macros and Visual Basic for Applications (VBA) with Excel

Objectives Add controls, such as command buttons, options buttons, and check boxes to a worksheet Assign properties to controls Use VBA to write a procedure to automate data entry into a worksheet Review a digital signature on a workbook Using Macros and Visual Basic for Applications (VBA) with Excel

Project – Green Valley Conservation Group Using Macros and Visual Basic for Applications (VBA) with Excel

General Project Guidelines Determine the actions you want to automate, and plan the steps to create a macro Create the first user interface Determine properties for controls in the user interface Establish the Visual Basic code needed for each control Create the second user interface Evaluate the completed user interface through testing Using Macros and Visual Basic for Applications (VBA) with Excel

Unprotecting a Password-Protected Worksheet Click the Unprotect Sheet button (Review tab | Changes group) to display the Unprotect Sheet dialog box Type the password in the Password text box Click the OK button to unprotect the worksheet Using Macros and Visual Basic for Applications (VBA) with Excel

Unprotecting a Password-Protected Worksheet Using Macros and Visual Basic for Applications (VBA) with Excel

Click the File tab to display the Backstage view Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the File tab to display the Backstage view Click the Options command to display the Excel Options dialog box Click the Customize Ribbon tab to display the Customize Ribbon tools Click the Developer check box in the Main Tabs list to select the Developer tab for display on the Ribbon Using Macros and Visual Basic for Applications (VBA) with Excel

Click the OK button to display the Developer tab on the Ribbon Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the OK button to display the Developer tab on the Ribbon Click the Macro Security button (Developer tab | Code group) to display the Trust Center dialog box Click the ‘Enable all macros’ option button to select it Click the OK button to close the dialog box and enable macros Using Macros and Visual Basic for Applications (VBA) with Excel

Click the File tab to display the Backstage view Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Click the File tab to display the Backstage view Click the Save As command to display the Save As dialog box When the Save As dialog box is displayed, click the ‘Save as type’ button to display a list of file types Click Excel Macro-Enabled Workbook in the ‘Save as type’ list to select the appropriate file type Click the Save button to save the workbook as an Excel Macro-Enabled Workbook file Using Macros and Visual Basic for Applications (VBA) with Excel

Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Using Macros and Visual Basic for Applications (VBA) with Excel

Displaying the Developer Tab, Enabling Macros, and Saving a Workbook as a Macro-Enabled Workbook Using Macros and Visual Basic for Applications (VBA) with Excel

Converting Names to Proper Case Using Macros and Visual Basic for Applications (VBA) with Excel

Recording a Macro Click the Use Relative References button (Developer tab | Code group) so that the macro uses relative cell references when selecting cells Click the Record Macro button (Developer tab | Code group) to display the Record Macro dialog box Enter the desired name and shortcut key, select the desired store location, and enter the desired description Click the OK button to begin recording the macro and change the Record Macro button to the Stop Recording button Perform the desired actions to add to the macro Click the Stop Recording button (Developer tab | Code group) to stop recording the worksheet activities Using Macros and Visual Basic for Applications (VBA) with Excel

Recording a Macro Using Macros and Visual Basic for Applications (VBA) with Excel

Setting the Macro Security Level to Medium Click the Macro Security button (Developer tab | Code group) to display the Trust Center dialog box Click the ‘Disable all macros with notification’ option button Click the OK button to close the dialog box Using Macros and Visual Basic for Applications (VBA) with Excel

Setting the Macro Security Level to Medium Using Macros and Visual Basic for Applications (VBA) with Excel

Opening a Workbook with Macros and Executing a Macro Open the desired workbook containing a macro Click the Enable Content button in the Security Warning bar to open the workbook with macros enabled Click the desired macro’s shortcut key to run the macro Using Macros and Visual Basic for Applications (VBA) with Excel

Viewing and Printing a Macro’s VBA Code Click the Macros button (Developer tab | Code group) to display the Macro dialog box When the Macro dialog box is displayed, click the name of the macro to view and print Click the Edit button to display the Microsoft Visual Basic Editor Click File on the menu bar to display the File menu Click the Print command to display the Print dialog box Click the OK button to print the macro code Click the Microsoft Visual Basic Editor Close button on the right side of the title bar to close the Visual Basic Editor window Using Macros and Visual Basic for Applications (VBA) with Excel

Viewing and Printing a Macro’s VBA Code Using Macros and Visual Basic for Applications (VBA) with Excel

Click the desired macro to add Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Right-click anywhere on the Quick Access Toolbar to display the shortcut menu Click the Customize Quick Access Toolbar command on the shortcut menu to display the Customize the Quick Access Toolbar page of the Excel Options dialog box Click the ‘Choose commands from’ box arrow to display a list of commands to add to the Quick Access Toolbar Click Macros in the ‘Choose commands from’ list to display a list of macros Click the desired macro to add Using Macros and Visual Basic for Applications (VBA) with Excel

Click the Modify button to display the Modify Button dialog box Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Click the Add button to add the macro to the Customize Quick Access Toolbar list Click the Modify button to display the Modify Button dialog box Click the desired icon in the Symbol list to select it Click the OK button to assign the icon to the new command and to close the dialog box Click the OK button to close the dialog box Click the new button on the Quick Access Toolbar to run the macro Using Macros and Visual Basic for Applications (VBA) with Excel

Adding a Button to the Quick Access Toolbar, Assigning the Button a Macro, and Using the Button Using Macros and Visual Basic for Applications (VBA) with Excel

Adding a Command Button Control to the Worksheet Click the Insert button (Developer tab | Controls group) to display the Controls gallery Click the Command Button button in the ActiveX Controls area of the Controls gallery (column 1, row 1 of ActiveX area) to switch to Design mode Move the mouse pointer (a crosshair) to the desired location for the command button Drag the mouse pointer to draw the command button Release the mouse button to add the Command Button control with the default caption CommandButton1 Using Macros and Visual Basic for Applications (VBA) with Excel

Adding a Command Button Control to the Worksheet Using Macros and Visual Basic for Applications (VBA) with Excel

Setting the Command Button Control Properties With the Command Button control selected and Excel in Design mode, click the Properties button (Developer tab | Controls group) to open the Properties window for the Command Button control If necessary, when the Properties window opens, click the Alphabetic tab Click Caption in the Properties list, double-click the entry in the Caption box, and then type the desired caption Click ForeColor in the Properties list, click the ForeColor arrow, and then click the Palette tab to display a palette of colors to apply to the button text Using Macros and Visual Basic for Applications (VBA) with Excel

Setting the Command Button Control Properties Select the desired color Click Font in the Properties list and then click the ellipsis button to display the Font dialog box When the Font dialog box appears, click the desired font, font style, and size Click the OK button to display the Command Button control Using Macros and Visual Basic for Applications (VBA) with Excel

Setting the Command Button Control Properties Using Macros and Visual Basic for Applications (VBA) with Excel

Entering the New Data Button Procedure Using the Visual Basic Editor Double-click the button to display the Microsoft Visual Basic Editor When the Microsoft Visual Basic Editor starts, if the Project Explorer window appears on the left, click its Close button If necessary, double-click the title bar of the Microsoft Visual Basic window to maximize it Click to the left of the letter P in the word Private on the first line and press the enter key to add a blank line before the Sub statement Position the insertion point on a blank line between the Sub and End Sub statements Using Macros and Visual Basic for Applications (VBA) with Excel

Entering the New Data Button Procedure Using the Visual Basic Editor Enter the desired code Click the Close button on the right side of the Microsoft Visual Basic title bar to return to the worksheet Click the Close button on the right side of the Properties window to close the window Click the Design Mode button to return to Run mode Using Macros and Visual Basic for Applications (VBA) with Excel

Entering the New Data Button Procedure Using the Visual Basic Editor Using Macros and Visual Basic for Applications (VBA) with Excel

Adding Form Controls to a User Interface Click the Insert button (Developer tab | Controls group) to display the Controls gallery Click the Option Button button in the Form Controls area in the Controls gallery Drag the mouse pointer to the desired location Click the Check Box button in the Form Controls area in the Controls gallery Using Macros and Visual Basic for Applications (VBA) with Excel

Adding Form Controls to a User Interface Using Macros and Visual Basic for Applications (VBA) with Excel

Grouping Option Buttons in a User Interface Click the Insert button (Developer tab | Controls group) to display the Controls gallery Click the Group Box button in the Form Controls area in the Controls gallery Drag the mouse pointer so the Group Box control is in the desired location Using Macros and Visual Basic for Applications (VBA) with Excel

Grouping Option Buttons in a User Interface Using Macros and Visual Basic for Applications (VBA) with Excel

Formatting the Option Button Controls With Excel in Design mode, click the option button control to format Use the sizing handles to resize the option button Right-click the control to display the shortcut menu Click Edit Text on the shortcut menu so you can edit the control text Delete the text in the control and type the replacement text Select the control(s) to resize Click the Align button (Drawing Tools Format tab | Arrange group) to display the alignment options Click the desired alignment option Using Macros and Visual Basic for Applications (VBA) with Excel

Formatting the Option Button Controls Using Macros and Visual Basic for Applications (VBA) with Excel

Recording User Input to Another Location on the Worksheet Right-click the control to link to display the shortcut menu Click Format Control to display the Format Control dialog box If necessary, click the Control tab to display the Control settings Enter the desired cell in the Cell link box to enter the identity of the control in that cell Click the OK button to close the dialog box Using Macros and Visual Basic for Applications (VBA) with Excel

Recording User Input to Another Location on the Worksheet Using Macros and Visual Basic for Applications (VBA) with Excel

Assigning Names to Cells Select the cell to name Click the Name Manager button (Formulas tab | Defined Names group) to open the Name Manager dialog box Click the New button to open the New Name dialog box Enter the desired name Click the OK button to enter the cell name Click the Close button to close the dialog box Using Macros and Visual Basic for Applications (VBA) with Excel

Assigning Names to Cells Using Macros and Visual Basic for Applications (VBA) with Excel

Assigning Names to Cells Using Macros and Visual Basic for Applications (VBA) with Excel

Entering the Command Button Procedures Using the Visual Basic Editor With the command button selected and Excel in Design mode, click the View Code button (Developer tab | Controls group) to display the Microsoft Visual Basic Editor Click the Object box arrow at the top of the window and then click the name of the command button Enter the desired VBA code Using Macros and Visual Basic for Applications (VBA) with Excel

Entering the Command Button Procedures Using the Visual Basic Editor Using Macros and Visual Basic for Applications (VBA) with Excel

Removing the Outline from the Group Control Switch to the Visual Basic Editor Press the CTRL+G keys to open the Immediate window Type activesheet.groupboxes.visible = false and press ENTER to remove the box from around the group control Using Macros and Visual Basic for Applications (VBA) with Excel

Removing the Outline from the Group Control Using Macros and Visual Basic for Applications (VBA) with Excel

Preparing and Protecting the Worksheet and Saving the Worksheet Click File on the Ribbon to open the Backstage view Click Options to display the Excel Options dialog box Click Advanced in the left pane to display the advanced options Click the Show page breaks and ‘Show a zero in cells that have zero value’ check boxes to deselect them Click the OK button to close the dialog box Click the Gridlines, Formula Bar, and Headings check boxes (View tab | Show group) to deselect them Click the Minimize the Ribbon button on the title bar to minimize the Ribbon Using Macros and Visual Basic for Applications (VBA) with Excel

Preparing and Protecting the Worksheet and Saving the Worksheet Click the Protect Sheet button (Review tab | Changes group) to display the Protect Sheet dialog box Type the desired password in the ‘Password to unprotect sheet’ text box Verify the password when prompted Click the OK button to close the dialog box Click the Save button on the Quick Access Toolbar to save the workbook Using Macros and Visual Basic for Applications (VBA) with Excel

Preparing and Protecting the Worksheet and Saving the Worksheet Using Macros and Visual Basic for Applications (VBA) with Excel

Chapter Summary Use passwords to assign protected and unprotected status to a worksheet Use the macro recorder to create a macro Execute a macro and view and print code for a macro Customize the Quick Access Toolbar by adding a button Understand Visual Basic for Applications (VBA) code and explain event-driven programs Using Macros and Visual Basic for Applications (VBA) with Excel

Chapter Summary Add controls, such as command buttons, options buttons, and check boxes to a worksheet Assign properties to controls Use VBA to write a procedure to automate data entry into a worksheet Review a digital signature on a workbook Using Macros and Visual Basic for Applications (VBA) with Excel

Microsoft Excel 2010 Chapter 10 Complete