LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY
By purchasing or using this book and disc (the Work), you agree that this license grants permission to use the contents contained herein, including the disc, but does not give you the right of ownership to any of the textual content in the book / disc or ownership to any of the information or products contained in it. This license does not permit uploading of the Work onto the Internet or on a network (of any kind) without the written consent of the Publisher. Duplication or dissemination of any text, code, simulations, images, etc. contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the Publisher or the owner of the content, etc., in order to reproduce or network any portion of the textual material (in any media) that is contained in the Work.
MERCURY LEARNING AND INFORMATION (MLI or the Publisher) and anyone involved in the creation, writing, or production of the companion disc, accompanying algorithms, code, or computer programs (the software), and any accompanying Web site or software of the Work, cannot and do not warrant the performance or results that might be obtained by using the contents of the Work. The author, developers, and the Publisher have used their best efforts to insure the accuracy and functionality of the textual material and/or programs contained in this package; we, however, make no warranty of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold as is without warranty (except for defective materials used in manufacturing the book or due to faulty workmanship).
The author, developers, and the publisher of any accompanying content, and anyone involved in the composition, production, and manufacturing of this work will not be liable for damages of any kind arising out of the use of (or the inability to use) the algorithms, source code, computer programs, or textual material contained in this publication. This includes, but is not limited to, loss of revenue or profit, or other incidental, physical, or consequential damages arising out of the use of this Work.
The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and/or disc, and only at the discretion of the Publisher. The use of implied warranty and certain exclusions vary from state to state, and might not apply to the purchaser of this product.
MICROSOFT
EXCEL PROGRAMMING
Pocket Primer
Julitta Korol
MERCURY LEARNING AND INFORMATION
Dulles, Virginia
Boston, Massachusetts
New Delhi
Copyright 2015 by MERCURY LEARNING AND INFORMATION LLC. All rights reserved.
This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means, media, electronic display or mechanical display, including, but not limited to, photocopy, recording, Internet postings, or scanning, without prior permission in writing from the publisher.
Publisher: David Pallai
MERCURY LEARNING AND Information
22841 Quicksilver Drive
Dulles, VA 20166
www.merclearning.com
800-232-0223
J.Korol. Microsoft Excel Programming Pocket Primer.
ISBN: 978-1-942270-01-0
The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others.
Library of Congress Control Number: 2015935261
1516321 Printed in the United States of America
This book is printed on acid-free paper.
Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at 800-232-0223 (toll free).
All of our titles are available in digital format at . The sole obligation of MERCURY LEARNING AND INFORMATION to the purchaser is to replace the disc, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.
For Jola
Start at the beginning and see where it takes youBut make sure you have a plan.
CONTENTS
ACKNOWLEDGMENTS
A s years pass and we gain more and more knowledge on a particular subject there is a tendency to publish books for people who want to know it all. But the truth is that we really dont have time to read all the printed pages. I thank my publisher, David Pallai, for suggesting that I consider creating a smaller book that will serve as a starting point for anyone attempting to get into VBA programming in Excel. I hope that you as a reader of this primer book will appreciate this short book and the knowledge gained from its pages will not only allow you to continue your programming journey but also take you places you never thought possible.
Im also thankful to Jennifer Blaney for her expert management of this book project. I owe a heartfelt thanks to my copyeditor at Educators International Press for the thorough review of the manuscript. I am grateful to the compositor, Tutis Innovative Solutions PTE LTD, for all the typesetting efforts that gave this book the easy to follow look and feel.
A special thank you goes to the Long Island Railroad for providing me with a seat on the train so I could use my laptop to write while commuting to my day job.
Julitta Korol
Brooklyn, New York
April, 2015
INTRODUCTION
B ack in the 90s, I wrote my first book on Excel macro programming. It was short and sweet. It contained the exact steps you needed to follow to automate various aspects of your Excel spreadsheets. If you worked with Excel this book instantly made you an Office hero and gave you skills for advancement. Over two decades have passed and Excel continues to be the worlds number 1 spreadsheet. It is my strong belief that if you invest your time in Excel it will pay over and over again for many more years to come. But, wait, youve got to progress beyond the tools provided by the built-in user interface. Forget the menus. Do your own thing. Automating Excel is something everyone can do. With the right training, that is. This books purpose is to introduce you to Excel built-in language, known as Visual Basic for Applications (VBA). With VBA you can begin delegating repetitive tasks to Excel while freeing your time for projects that are more fun to do. Besides, knowing how to program these days is a lucrative skill. It will get you a well-paying and secure job.
This book is short and hopefully sweet as well. It was designed for someone like you who needs to master Excel programming fundamentals without spending too much time. Most of the time all you need is a short book to get you started. Its less overwhelming to deal with a new subject in smaller chunks. The VBA Programming Pocket Primer series will show you only the things you need to know to feel at home with VBA. What you learn in this book on Excel programming will apply to, say, Access programming. Just see my other book, the Microsoft Access Programming Pocket Primer , to see what I mean. Hows that for knowledge transfer? Learn in Excel, use it in Access or another Microsoft Office application. I call this sweet learning.
If you are looking for in-depth knowledge of Excel programming (and have time to read through a 1,000 page book), then go ahead and try some of my thicker books. See for details.