Date post: | 28-Dec-2015 |
Category: |
Documents |
Upload: | hillary-hamilton |
View: | 214 times |
Download: | 0 times |
OV 1 - 1Copyright © 2011 Element K Content LLC. All rights reserved.
Create a Macro with the Macro Recorder Edit a Macro Debug a Macro Customize the Quick Access Toolbar and Hotkeys Working with Macro Security
Developing Macros
OV 1 - 2Copyright © 2011 Element K Content LLC. All rights reserved.
Object-Oriented Programming
Modeled like real-time objectModeled like real-time object
Information associated with an objectInformation associated with an object
OV 1 - 3Copyright © 2011 Element K Content LLC. All rights reserved.
Sub font2Arial() Cells.Select Selection.Font.Name = "Arial"End Sub
Macros
Code that accomplishesfrequently repeated taskCode that accomplishesfrequently repeated task
Unique macro nameUnique macro name
OV 1 - 4Copyright © 2011 Element K Content LLC. All rights reserved.
Macro Options
OV 1 - 5Copyright © 2011 Element K Content LLC. All rights reserved.
The Macro Recorder
Start recordingStart recording
Perform tasks in the worksheet
Perform tasks in the worksheet
Reusable generated macro code
Reusable generated macro code
OV 1 - 6Copyright © 2011 Element K Content LLC. All rights reserved.
Personal Macro Workbook
Storage location that any
Excel workbook can access
Storage location that any
Excel workbook can access
OV 1 - 7Copyright © 2011 Element K Content LLC. All rights reserved.
Visual Basic Editor
Standard toolbar Standard toolbar
Object BrowserObject Browser
Code windowCode window
Project ExplorerProject
Explorer
Properties window
Properties window
Immediatewindow
Immediatewindow
OV 1 - 8Copyright © 2011 Element K Content LLC. All rights reserved.
Modules
Code window displaying macros in Module1
Code window displaying macros in Module1
Module1 selected in Project ExplorerModule1 selected
in Project Explorer
OV 1 - 9Copyright © 2011 Element K Content LLC. All rights reserved.
The Modules Folder
The Modules folder displayed in Project Explorer
The Modules folder displayed in Project Explorer
OV 1 - 10Copyright © 2011 Element K Content LLC. All rights reserved.
Objects
Real-time components used as objects in macros
Real-time components used as objects in macros
OV 1 - 11Copyright © 2011 Element K Content LLC. All rights reserved.
Properties
Components that describe an object
Components that describe an object
OV 1 - 12Copyright © 2011 Element K Content LLC. All rights reserved.
Methods
Actions that can be performed on an object
Actions that can be performed on an object
OV 1 - 13Copyright © 2011 Element K Content LLC. All rights reserved.
Sub AddTotals()'A macro that inserts the SUM function at the bottom of a'column of unknown length.
Dim x As Integer
'Declare the Range objects here: Dim myData As Range Dim myTotal As Range For x = 1 To Worksheets.Count
Worksheets(x).Select
'Set the data range object:Range("A7").SelectSet myData = ActiveCell.CurrentRegion
VBA Comments
Comments explaining purpose of macro
Comments explaining purpose of macro
Comment explaining purpose of code
Comment explaining purpose of code
Apostrophe used to start comment line
Apostrophe used to start comment line
OV 1 - 14Copyright © 2011 Element K Content LLC. All rights reserved.
The Debugging Process
Set up environment
Back upRun code with error
Determine problem
Reset dataExecute code line by line
to find the error
Fix code error Retest to ensure error is fixed
OV 1 - 15Copyright © 2011 Element K Content LLC. All rights reserved.
Debugging Tools
Tools that start, stop, and reset macro execution
Tools that start, stop, and reset macro execution
Toggle Breakpoint toolToggle Breakpoint tool Step toolsStep tools
OV 1 - 16Copyright © 2011 Element K Content LLC. All rights reserved.
Digital Certificates
Unique informationabout the certificate holder
Unique informationabout the certificate holder
OV 1 - 17Copyright © 2011 Element K Content LLC. All rights reserved.
Digital Signatures
Digitally signed worksheet cannot be edited
Digitally signed worksheet cannot be edited
Signature iconSignature icon
OV 1 - 18Copyright © 2011 Element K Content LLC. All rights reserved.
Macro Security Settings
OV 1 - 19Copyright © 2011 Element K Content LLC. All rights reserved.
1. Do you think that the Macro Recorder is a useful tool? Why or why not?
2. How does the Personal Macro Workbook relate to the creation and use of custom toolbars, buttons, and menus?
Reflective Questions