Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
164 views10 pages

Excel VBA Programming For Dummies, 6th Edition Kusleika

Excel VBA Programming For Dummies, 6th Edition by Dick Kusleika provides a comprehensive guide to using VBA in Excel, covering topics from basic programming concepts to advanced techniques. The book includes practical examples, tips, and resources to help users effectively automate tasks and enhance their Excel experience. Published by John Wiley & Sons, it is available for download on YakiBooki.com.

Uploaded by

zuhoshira1973
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)
164 views10 pages

Excel VBA Programming For Dummies, 6th Edition Kusleika

Excel VBA Programming For Dummies, 6th Edition by Dick Kusleika provides a comprehensive guide to using VBA in Excel, covering topics from basic programming concepts to advanced techniques. The book includes practical examples, tips, and resources to help users effectively automate tasks and enhance their Excel experience. Published by John Wiley & Sons, it is available for download on YakiBooki.com.

Uploaded by

zuhoshira1973
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
You are on page 1/ 10

Excel VBA Programming For Dummies, 6th Edition Kusleika

https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/

This Book is Available on YakiBooki.com


Excel VBA Programming For Dummies, 6th Edition Kusleika

https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/

This Book is Available on YakiBooki.com


Excel VBA Programming For Dummies, 6th Edition Kusleika

https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/

Excel VBA
Programming
6th Edition

by Dick Kusleika

This Book is Available on YakiBooki.com


Excel VBA Programming For Dummies, 6th Edition Kusleika

Excel® VBA Programming For Dummies®


https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com

Copyright © 2022 by John Wiley & Sons, Inc., Hoboken, New Jersey

Media and software compilation copyright © 2012 by John Wiley & Sons, Inc. All rights reserved.

Published simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to
the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River
Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related
trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written
permission. Microsoft and Excel are trademarks or registered trademarks of Microsoft Corporation in the United
States and other countries. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc.
is not associated with any product or vendor mentioned in this book.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHORS HAVE USED THEIR
BEST EFFORTS IN PREPARING THIS WORK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT
TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL
WARRANTIES, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES
REPRESENTATIVES, WRITTEN SALES MATERIALS OR PROMOTIONAL STATEMENTS FOR THIS WORK. THE FACT
THAT AN ORGANIZATION, WEBSITE, OR PRODUCT IS REFERRED TO IN THIS WORK AS A CITATION AND/OR
POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE PUBLISHER AND AUTHORS
ENDORSE THE INFORMATION OR SERVICES THE ORGANIZATION, WEBSITE, OR PRODUCT MAY PROVIDE OR
RECOMMENDATIONS IT MAY MAKE. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS
NOT ENGAGED IN RENDERING PROFESSIONAL SERVICES. THE ADVICE AND STRATEGIES CONTAINED HEREIN
MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A SPECIALIST WHERE APPROPRIATE.
FURTHER, READERS SHOULD BE AWARE THAT WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR
DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. NEITHER THE PUBLISHER
NOR AUTHORS SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING
BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES.

For general information on our other products and services, please contact our Customer Care Department within
the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit
https://hub.wiley.com/community/support/dummies.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with
standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to
media such as a CD or DVD that is not included in the version you purchased, you may download this material at
http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number: 2021951691

ISBN 978-1-119-84307-8 (pbk); ISBN 978-1-119-84308-5 (ebk); ISBN 978-1-119-84309-2 (ebk)

This Book is Available on YakiBooki.com


Excel VBA Programming For Dummies, 6th Edition Kusleika
Contents at a Glance
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/
Part 1: Starting Excel VBA Programming . . . . . . . . . . . . . . . . . . . . . . 7
CHAPTER 1: Getting to Know VBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
CHAPTER 2: Building Simple Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Part 2: Employing VBA with Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29


CHAPTER 3: Working in the Visual Basic Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
CHAPTER 4: Introducing the Excel Object Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
CHAPTER 5: VBA Sub and Function Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
CHAPTER 6: Using the Excel Macro Recorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

Part 3: Programming Concepts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97


CHAPTER 7: Essential VBA Language Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
CHAPTER 8: Working with Range Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
CHAPTER 9: Using VBA and Worksheet Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

CHAPTER 10: Controlling Program Flow and Making Decisions . . . . . . . . . . . . . . . . . . 151

CHAPTER 11: Automatic Procedures and Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

CHAPTER 12: Error-Handling Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

CHAPTER 13: Bug Extermination Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

CHAPTER 14: VBA Programming Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219

Part 4: Communicating with Your Users . . . . . . . . . . . . . . . . . . . . 243


CHAPTER 15: Simple Dialog Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
CHAPTER 16: UserForm Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
CHAPTER 17: Using UserForm Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

CHAPTER 18: UserForm Techniques and Tricks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

CHAPTER 19: Accessing Your Macros through the User Interface . . . . . . . . . . . . . . . . 329

Part 5: Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343


CHAPTER 20: Creating Worksheet Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
CHAPTER 21: Creating Excel Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

Part 6: The Part of Tens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377


CHAPTER 22: Ten Handy Visual Basic Editor Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
CHAPTER 23: Resources for VBA Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

CHAPTER 24: Ten VBA Do’s and Don’ts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

This Book is Available on YakiBooki.com


Excel VBA Programming For Dummies, 6th Edition Kusleika

https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/

This Book is Available on YakiBooki.com


Excel VBA Programming For Dummies, 6th Edition Kusleika
Table of Contents
INTRODUCTION ...................................................1
https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/
About This Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Typographical conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Macro security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Foolish Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Icons Used in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Beyond the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Where to Go from Here . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

PART 1: STARTING EXCEL VBA PROGRAMMING . . . . . . . . . . . . . 7

CHAPTER 1: Getting to Know VBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


Understanding VBA Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Knowing What VBA Can Do . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
Inserting a bunch of text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Automating a task you perform frequently . . . . . . . . . . . . . . . . . . . .11
Automating repetitive operations . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Creating a custom command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
Creating a custom button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Developing new worksheet functions . . . . . . . . . . . . . . . . . . . . . . . .12
Creating custom add-ins for Excel . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Getting the Most from VBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Knowing what VBA does best . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Recognizing the disadvantages of using VBA . . . . . . . . . . . . . . . . . .13
Understanding VBA Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
Ensuring Excel Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16

CHAPTER 2: Building Simple Macros. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17


Displaying the Developer Tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Creating a Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Preparing the Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Recording a Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Running the Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Viewing a Macro in the Visual Basic Editor . . . . . . . . . . . . . . . . . . . . . . .22
Modifying the Macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Saving Workbooks That Contain Macros . . . . . . . . . . . . . . . . . . . . . . . . .25
Understanding Macro Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25

This Book is Available on YakiBooki.com


Table of Contents v
Excel VBA Programming For Dummies, 6th Edition Kusleika
PART 2: EMPLOYING VBA WITH EXCEL . . . . . . . . . . . . . . . . . . . . . . . 29

CHAPTER 3: Working in the Visual Basic Editor . . . . . . . . . . . . . . . . . . . . 31


Getting to Know the Visual Basic Editor . . . . . . . . . . . . . . . . . . . . . . . . . .31
Activating the VBE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/
Exploring VBE components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Working with the Project Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Adding a new VBA module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Working with a Code Pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Minimizing and maximizing windows. . . . . . . . . . . . . . . . . . . . . . . . .36
Looking at the parts of a module . . . . . . . . . . . . . . . . . . . . . . . . . . . .37
Getting VBA code into a module . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
Entering code directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
Using the macro recorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
Copying VBA code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Customizing the VBE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Using the Editor tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Using the Editor Format tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Using the General tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Using the Docking tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48

CHAPTER 4: Introducing the Excel Object Model . . . . . . . . . . . . . . . . . . 51


Working with the Excel Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Understanding the object hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . .52
Referring to objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Diving into Object Properties and Methods . . . . . . . . . . . . . . . . . . . . . .57
Setting object properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Taking action with object methods . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Triggering actions with object events . . . . . . . . . . . . . . . . . . . . . . . . .61
Finding Out More from VBA Resources . . . . . . . . . . . . . . . . . . . . . . . . . .62
Using VBA’s Help system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Using the Object Browser. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
Automatically listing properties and methods . . . . . . . . . . . . . . . . .64

CHAPTER 5: VBA Sub and Function Procedures . . . . . . . . . . . . . . . . . . . 67


Understanding Subs versus Functions . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Looking at Sub procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Looking at Function procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Naming Subs and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
Executing Sub procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
Executing the Sub procedure directly . . . . . . . . . . . . . . . . . . . . . . . .72
Executing the procedure from the Macro dialog box . . . . . . . . . . .73
Executing a macro by using a shortcut key . . . . . . . . . . . . . . . . . . . .74
Executing the procedure from a button or shape . . . . . . . . . . . . . .75
Executing the procedure from another procedure . . . . . . . . . . . . .77
Executing the procedure from the Immediate window . . . . . . . . . .77

vi This Book
Excel VBA Programming For is Available
Dummies on YakiBooki.com
Excel VBA Programming For Dummies, 6th Edition Kusleika
Executing Function Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
Calling the function from a Sub procedure . . . . . . . . . . . . . . . . . . . .78
Calling a function from the Immediate window . . . . . . . . . . . . . . . .79
Calling a function from a worksheet formula . . . . . . . . . . . . . . . . . .80

CHAPTER 6: Using the Excel Macro Recorder . . . . . . . . . . . . . . . . . . . . . . 83


https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/
Recording Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Preparing to Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
Choosing Between Relative and Absolute Mode . . . . . . . . . . . . . . . . . .86
Recording in absolute mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Recording in relative mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87
Watching the Macro Recorder in Action . . . . . . . . . . . . . . . . . . . . . . . . .89
Specifying Recording Options for Your Macro . . . . . . . . . . . . . . . . . . . .91
Streamlining Code Generated by the Macro Recorder . . . . . . . . . . . . .92

PART 3: PROGRAMMING CONCEPTS . . . . . . . . . . . . . . . . . . . . . . . . . 97

CHAPTER 7: Essential VBA Language Elements . . . . . . . . . . . . . . . . . . . . 99


Using Comments in Your VBA Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
Using Variables, Constants, and Data Types . . . . . . . . . . . . . . . . . . . . .101
Understanding variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
What are VBA’s data types? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Declaring and scoping variables . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
Working with constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Using premade constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Working with strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Working with dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
Using Assignment Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
Assignment statement examples . . . . . . . . . . . . . . . . . . . . . . . . . . .113
About that equal sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
Smooth operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
Working with Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
Declaring arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
Multidimensional arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
Dynamic arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
Using Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118

CHAPTER 8: Working with Range Objects . . . . . . . . . . . . . . . . . . . . . . . . . 119


Referring to Range Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Referring to a Range Using Properties . . . . . . . . . . . . . . . . . . . . . . . . . .121
The Cells property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
The O set property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
The Resize property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123

This Book is Available on YakiBooki.com


Table of Contents vii
Excel VBA Programming For Dummies, 6th Edition Kusleika
Working with Range Object Properties . . . . . . . . . . . . . . . . . . . . . . . . .124
The Value property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
The Text property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
The Count property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
The Column and Row properties . . . . . . . . . . . . . . . . . . . . . . . . . . .126
https://www.yakibooki.com/download/excel-vba-programming-for-dummies-6th-edition/
The Address property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
The HasFormula property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
The Font property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
The Interior property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
The Formula property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
The NumberFormat property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
Taking Action with Range Object Methods . . . . . . . . . . . . . . . . . . . . . .131
The Select method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
The Copy and Paste methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
The Clear method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
The Delete method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133

CHAPTER 9: Using VBA and Worksheet Functions . . . . . . . . . . . . . . . 135


Understanding Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
Using Built-In VBA Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Working with dates and times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Manipulating strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
Identifying objects and data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
VBA functions that do more than return a value . . . . . . . . . . . . . .140
Discovering VBA functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
Using Worksheet Functions in VBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
Worksheet function examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
Entering worksheet functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
More about using worksheet functions . . . . . . . . . . . . . . . . . . . . . .148
Using Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148

CHAPTER 10: Controlling Program Flow and


Making Decisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Going with the Flow, Dude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
The GoTo Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152
Decisions, Decisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
The If-Then structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
The Select Case structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .158
Knocking Your Code for a Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
For-Next loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
Do-While loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167
Do-Until loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168
Using For Each-Next Loops with Collections . . . . . . . . . . . . . . . . . . . . .168

viii Excel VBAThis BookForisDummies


Programming Available on YakiBooki.com

You might also like