Home Page Icon
Home Page
Table of Contents for
Excel® Macros For Dummies®
Close
Excel® Macros For Dummies®
by Michael Alexander
Excel Macros For Dummies
Cover
Cover
Introduction
About This Book
Foolish Assumptions
Icons Used In This Book
Beyond the Book
Where to Go from Here
Part I: Holy Macro Batman!
Chapter 1: Macro Fundamentals
Why Use a Macro?
Macro Recording Basics
Comparing Absolute and Relative Macro Recording
Other Macro Recording Concepts
Examples of Macros in Action
Chapter 2: Getting Cozy with Visual Basic Editor
Working in Visual Basic Editor
Working with the Project Window
Working with a Code Window
Customizing the VBA Environment
Chapter 3: The Anatomy of Macros
An Overview of the Excel Object Model
A Brief Look at Variables
Understanding Event Procedures
Error Handling in a Nutshell
Part II: Making Short Work of Workbook Tasks
Chapter 4: Working with Workbooks
Creating a Workbook from Scratch
Saving a Workbook when a Particular Cell Is Changed
Saving a Workbook before Closing
Protecting a Worksheet on Workbook Close
Unprotecting a Worksheet on Workbook Open
Opening a Workbook to a Specific Tab
Opening a Specific Workbook Defined by the User
Determining Whether a Workbook Is Already Open
Determining Whether a Workbook Exists in a Directory
Closing All Workbooks at Once
Printing All Workbooks in a Directory
Preventing the Workbook from Closing Until a Cell Is Populated
Creating a Backup of a Current Workbook with Today’s Date
Chapter 5: Working with Worksheets
Adding and Naming a New Worksheet
Deleting All but the Active Worksheet
Hiding All but the Active Worksheet
How the macro works
Unhiding All Worksheets in a Workbook
Moving Worksheets Around
Sorting Worksheets by Name
Grouping Worksheets by Color
Copying a Worksheet to a New Workbook
Creating a Workbook for Each Worksheet
Printing Specified Worksheets
Protecting All Worksheets
Unprotecting All Worksheets
Creating a Table of Contents for Your Worksheets
Zooming In and Out of a Worksheet with Double-Click
Highlighting the Active Row and Column
Part III: One-Touch Data Manipulation
Chapter 6: Feeling at Home on the Range
Selecting and Formatting a Range
Creating and Selecting Named Ranges
Enumerating through a Range of Cells
Inserting Blank Rows in a Range
Unhiding All Rows and Columns
Deleting Blank Rows
Deleting Blank Columns
Limiting Range Movement to a Particular Area
Selecting and Formatting All Formulas in a Workbook
Finding and Selecting the First Blank Row or Column
Chapter 7: Manipulating Data with Macros
Copying and Pasting a Range
Converting All Formulas in a Range to Values
Performing the Text to Columns Command on All Columns
Converting Trailing Minus Signs
Trimming Spaces from All Cells in a Range
Truncating Zip Codes to the Left Five Digits
Padding Cells with Zeros
Replacing Blanks Cells with a Value
Adding Text to the Left or Right of Your Cells
Cleaning Up Nonprinting Characters
Highlighting Duplicates in a Range of Data
Hiding All Rows Except Rows Containing Duplicate Data
Selectively Hiding AutoFilter Drop-Down Arrows
Copying Filtered Rows to a New Workbook
Displaying Filtered Columns in the Status Bar
Part IV: Macro-Charging Reports and Emails
Chapter 8: Automating Common Reporting Tasks
Refreshing All Pivot Tables in a Workbook
Creating a Pivot Table Inventory Summary
Adjusting All Pivot Data Field Titles
Setting All Data Items to Sum
Applying Number Formatting to All Data Items
Sorting All Fields in Alphabetical Order
Applying Custom Sort to Data Items
Applying Pivot Table Restrictions
Applying Pivot Field Restrictions
Automatically Deleting Pivot Table Drill-Down Sheets
Printing a Pivot Table for Each Report Filter Item
Creating a Workbook for Each Report Filter Item
Resizing All Charts on a Worksheet
Aligning a Chart to a Specific Range
Creating a Set of Disconnected Charts
Printing All Charts on a Worksheet
Chapter 9: Sending Emails from Excel
Mailing the Active Workbook as an Attachment
Mailing a Specific Range as an Attachment
Mailing a Single Sheet as an Attachment
Sending Mail with a Link to Your Workbook
Mailing All Email Addresses in Your Contact List
Saving All Attachments to a Folder
Saving Certain Attachments to a Folder
Part V: The Part of Tens
Chapter 10: Ten Handy Visual Basic Editor Tips
Applying Block Comments
Copying Multiple Lines of Code
Jumping between Modules and Procedures
Teleporting to Your Functions
Staying in the Right Procedure
Stepping through Your Code
Stepping to a Specific Code Line
Stopping Code at a Predefined Point
Seeing Beginning and Ending Variable Values
Turning Off Auto Syntax Check
Chapter 11: Ten Places to Turn for Macro Help
Letting Excel Write the Macro for You
Using the VBA Help Files
Pilfering Code from the Internet
Leveraging User Forums
Visiting Expert Blogs
Mining YouTube for Video Training
Attending Live and Online Training Classes
Learning from Microsoft Office Dev Center
Dissecting Other Excel Files in Your Organization
Asking Your Local Excel Genius
Chapter 12: Ten Ways to Speed Up Your Macros
Halting Sheet Calculations
Disabling Sheet Screen Updating
Turning Off Status Bar Updates
Telling Excel to Ignore Events
Hiding Page Breaks
Suspending Pivot Table Updates
Steering Clear of Copy and Paste
Using the With Statement
Avoiding the Select Method
Limiting Trips to the Worksheet
About the Author
Cheat Sheet
Advertisement Page
Connect with Dummies
End User License Agreement
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Introduction
Excel® Macros For Dummies®
Visit
www.dummies.com/cheatsheet/excelmacros
to view this book's cheat sheet.
Table of Contents
Cover
Introduction
About This Book
Foolish Assumptions
Icons Used In This Book
Beyond the Book
Where to Go from Here
Part I: Holy Macro Batman!
Chapter 1: Macro Fundamentals
Why Use a Macro?
Macro Recording Basics
Comparing Absolute and Relative Macro Recording
Other Macro Recording Concepts
Examples of Macros in Action
Chapter 2: Getting Cozy with Visual Basic Editor
Working in Visual Basic Editor
Working with the Project Window
Working with a Code Window
Customizing the VBA Environment
Chapter 3: The Anatomy of Macros
An Overview of the Excel Object Model
A Brief Look at Variables
Understanding Event Procedures
Error Handling in a Nutshell
Part II: Making Short Work of Workbook Tasks
Chapter 4: Working with Workbooks
Creating a Workbook from Scratch
Saving a Workbook when a Particular Cell Is Changed
Saving a Workbook before Closing
Protecting a Worksheet on Workbook Close
Unprotecting a Worksheet on Workbook Open
Opening a Workbook to a Specific Tab
Opening a Specific Workbook Defined by the User
Determining Whether a Workbook Is Already Open
Determining Whether a Workbook Exists in a Directory
Closing All Workbooks at Once
Printing All Workbooks in a Directory
Preventing the Workbook from Closing Until a Cell Is Populated
Creating a Backup of a Current Workbook with Today’s Date
Chapter 5: Working with Worksheets
Adding and Naming a New Worksheet
Deleting All but the Active Worksheet
Hiding All but the Active Worksheet
How the macro works
Unhiding All Worksheets in a Workbook
Moving Worksheets Around
Sorting Worksheets by Name
Grouping Worksheets by Color
Copying a Worksheet to a New Workbook
Creating a Workbook for Each Worksheet
Printing Specified Worksheets
Protecting All Worksheets
Unprotecting All Worksheets
Creating a Table of Contents for Your Worksheets
Zooming In and Out of a Worksheet with Double-Click
Highlighting the Active Row and Column
Part III: One-Touch Data Manipulation
Chapter 6: Feeling at Home on the Range
Selecting and Formatting a Range
Creating and Selecting Named Ranges
Enumerating through a Range of Cells
Inserting Blank Rows in a Range
Unhiding All Rows and Columns
Deleting Blank Rows
Deleting Blank Columns
Limiting Range Movement to a Particular Area
Selecting and Formatting All Formulas in a Workbook
Finding and Selecting the First Blank Row or Column
Chapter 7: Manipulating Data with Macros
Copying and Pasting a Range
Converting All Formulas in a Range to Values
Performing the Text to Columns Command on All Columns
Converting Trailing Minus Signs
Trimming Spaces from All Cells in a Range
Truncating Zip Codes to the Left Five Digits
Padding Cells with Zeros
Replacing Blanks Cells with a Value
Adding Text to the Left or Right of Your Cells
Cleaning Up Nonprinting Characters
Highlighting Duplicates in a Range of Data
Hiding All Rows Except Rows Containing Duplicate Data
Selectively Hiding AutoFilter Drop-Down Arrows
Copying Filtered Rows to a New Workbook
Displaying Filtered Columns in the Status Bar
Part IV: Macro-Charging Reports and Emails
Chapter 8: Automating Common Reporting Tasks
Refreshing All Pivot Tables in a Workbook
Creating a Pivot Table Inventory Summary
Adjusting All Pivot Data Field Titles
Setting All Data Items to Sum
Applying Number Formatting to All Data Items
Sorting All Fields in Alphabetical Order
Applying Custom Sort to Data Items
Applying Pivot Table Restrictions
Applying Pivot Field Restrictions
Automatically Deleting Pivot Table Drill-Down Sheets
Printing a Pivot Table for Each Report Filter Item
Creating a Workbook for Each Report Filter Item
Resizing All Charts on a Worksheet
Aligning a Chart to a Specific Range
Creating a Set of Disconnected Charts
Printing All Charts on a Worksheet
Chapter 9: Sending Emails from Excel
Mailing the Active Workbook as an Attachment
Mailing a Specific Range as an Attachment
Mailing a Single Sheet as an Attachment
Sending Mail with a Link to Your Workbook
Mailing All Email Addresses in Your Contact List
Saving All Attachments to a Folder
Saving Certain Attachments to a Folder
Part V: The Part of Tens
Chapter 10: Ten Handy Visual Basic Editor Tips
Applying Block Comments
Copying Multiple Lines of Code
Jumping between Modules and Procedures
Teleporting to Your Functions
Staying in the Right Procedure
Stepping through Your Code
Stepping to a Specific Code Line
Stopping Code at a Predefined Point
Seeing Beginning and Ending Variable Values
Turning Off Auto Syntax Check
Chapter 11: Ten Places to Turn for Macro Help
Letting Excel Write the Macro for You
Using the VBA Help Files
Pilfering Code from the Internet
Leveraging User Forums
Visiting Expert Blogs
Mining YouTube for Video Training
Attending Live and Online Training Classes
Learning from Microsoft Office Dev Center
Dissecting Other Excel Files in Your Organization
Asking Your Local Excel Genius
Chapter 12: Ten Ways to Speed Up Your Macros
Halting Sheet Calculations
Disabling Sheet Screen Updating
Turning Off Status Bar Updates
Telling Excel to Ignore Events
Hiding Page Breaks
Suspending Pivot Table Updates
Steering Clear of Copy and Paste
Using the With Statement
Avoiding the Select Method
Limiting Trips to the Worksheet
About the Author
Cheat Sheet
Advertisement Page
Connect with Dummies
End User License Agreement
Guide
Cover
Table of Contents
Begin Reading
Pages
i
ii
v
vi
vii
viii
ix
x
xi
xii
1
2
3
4
5
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
29
30
31
32
33
34
35
36
37
38
39
40
41
43
44
45
46
47
48
49
50
51
52
53
54
55
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
269
270
271
272
273
274
275
276
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset