Schweitzer Fachinformationen
Wenn es um professionelles Wissen geht, ist Schweitzer Fachinformationen wegweisend. Kunden aus Recht und Beratung sowie Unternehmen, öffentliche Verwaltungen und Bibliotheken erhalten komplette Lösungen zum Beschaffen, Verwalten und Nutzen von digitalen und gedruckten Medien.
Your step-by-step guide to doing more with Microsoft Excel
Fully updated for the latest version of Office 365, Excel VBA Programming For Dummies will take your Excel knowledge to the next level. With a little background in Visual Basic for Applications (VBA) programming, you can go well beyond basic spreadsheets and functions. Learn the coding basics and syntax you need to write simple or complex macros that can automate your routine Excel tasks. Become an Excel power user by automating data management, user forms, pivot tables, and beyond. When you use VBA to perform Excel operations, you can reduce errors, save time, and integrate with other Microsoft applications. This handy guide also teaches you how to control the security settings for your macros and save macros to use across files and apps. Plus, you'll get updated coverage of Copilot AI integration. Your spreadsheets are about to get much more powerful.
This Dummies guide is right up your alley if you're an Excel user looking to learn some next-level features. Students and professionals alike will reap the benefits of automation, thanks to Excel VBA Programming For Dummies.
Dick Kusleika has more than 25 years' experience helping Office users get the most out of Microsoft's bestselling software. From online forums to blogs, books, and conferences, he delivers sound and straightforward advice to readers of all skill levels.
Introduction 1
Part 1: Starting Excel VBA Programming 7
Chapter 1: Getting to Know VBA 9
Chapter 2: Building Simple Macros 17
Part 2: Using 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 65
Part 3: Creating Code Automatically 81
Chapter 6: Using the Excel Macro Recorder 83
Chapter 7: Generating Code with Copilot 95
Part 4: Programming Concepts 107
Chapter 8: Essential VBA Language Elements 109
Chapter 9: Working with Range Objects 131
Chapter 10: Using VBA and Worksheet Functions 147
Chapter 11: Controlling Program Flow and Making Decisions 163
Chapter 12: Automatic Procedures and Events 183
Chapter 13: Error-Handling Techniques 205
Chapter 14: Bug Extermination Techniques 217
Chapter 15: VBA Programming Examples 231
Part 5: Communicating with Your Users 255
Chapter 16: Simple Dialog Boxes 257
Chapter 17: UserForm Basics 275
Chapter 18: Using UserForm Controls 293
Chapter 19: UserForm Techniques and Tricks 313
Chapter 20: Accessing Your Macros through the User Interface 341
Part 6: Putting It All Together 355
Chapter 21: Creating Worksheet Functions 357
Chapter 22: Creating Excel Add-Ins 379
Part 7: The Part of Tens 391
Chapter 23: Ten Handy Visual Basic Editor Tips 393
Chapter 24: Resources for VBA Help 403
Chapter 25: Ten VBA Do's and Don'ts 409
Index 415
Welcome, prospective Excel programmer. .
You no doubt have your reasons for picking up a book on VBA programming. Maybe you got a new job (congratulations!). Maybe you're trying to automate some of the repetitive data-crunching tasks you have to do. Maybe you're just a nerd at heart. Whatever the reason, thank you for choosing this book.
Inside, you find everything you need to get up and running with VBA - fast. Even if you don't have the foggiest idea of what programming is all about, this book can help. Unlike most programming books, this one is filled with information designed to include just what you need to know to quickly ramp your VBA programming skill set.
Go to any large bookstore (in person or online) and you'll find many Excel books. A quick overview can help you decide whether this book is truly right for you. This book
If you're using an older version of Excel, this book might be okay, but some things have changed. You'd probably be better off with one of the preceding editions of this book.
Oh, yeah - this is not an introductory Excel book. If you're looking for a general-purpose Excel book, check out either of the following books, both published by Wiley:
These books are also available in editions for earlier versions of Excel.
Notice that the title of this book isn't The Complete Guide to Microsoft 365 Excel VBA Programming For Dummies. This book doesn't cover all aspects of Excel programming - but then again, you probably don't want to know everything about this topic.
If you consume this book and find that you're hungry for a more comprehensive Excel programming book, you might try Excel 2019 Power Programming with VBA, also published by Wiley. And yes, editions for older versions of Excel are also available.
To make the content more accessible, I divided this book into seven parts:
Sometimes I refer to key combinations - which means you hold down one key while you press another. For example, Ctrl+Z means you hold down the Ctrl key while you press Z.
For menu commands, I use a distinctive character to separate items on the Ribbon or menu. For example, you use the following command to create a named range in a worksheet:
Formulas?????Defined Names?????Define Name
Formulas is the name of the tab at the top of the Ribbon, Defined Names is the name of the Ribbon group, and Define Name is the name of the Ribbon tool you click.
The Visual Basic Editor still uses old-fashioned menus and toolbars. So Tools?????Options means to choose the Tools menu and then choose the Options menu item.
Excel programming involves developing code - that is, the instructions VBA follows. All code in this book appears in a monospace font, like this:
Range("A1:A12").Select
Some long lines of code don't fit between the margins in this book. In such cases, I use the standard VBA line-continuation character sequence: a space followed by an underscore character. Here's an example:
Selection.PasteSpecial Paste:=xlValues, _ Operation:=xlNone, SkipBlanks:=False, _ Transpose:=False
When you enter this code, you can type it as written or place it on a single line (omitting the space-and-underscore combination).
It's a cruel world out there. It seems that some scam artist is always trying to take advantage of you or cause some type of problem. The world of computing is equally cruel. You probably know about computer viruses, which can cause some nasty things to happen to your system. But did you know that computer viruses can also reside in an Excel file? It's true. In fact, it's relatively easy to write a computer virus by using VBA. An unknowing user can open an Excel file and spread the virus to other Excel workbooks and to other people on your network.
Over the years, Microsoft has become increasingly concerned about security issues. This is a good thing, but it also means that Excel users need to understand how things work. You can check Excel's security settings by choosing File ????Options ????Trust Center ????Trust Center Settings. A plethora of options appear there, and people have been known to open that dialog box and never be heard from again.
If you click the Macro Settings tab (on the left side of the Trust Center dialog box), your options are as follows:
Consider this scenario: You spend a week writing a killer VBA program that will revolutionize your company. You test it thoroughly and then send it to your boss. They call you into their office and claim that your macro doesn't do anything. What's going on? Chances are, your boss's security setting doesn't allow macros to run. Or maybe they chose to go along with Microsoft's default suggestion and disable the macros when they opened the file.
Bottom line? Just because an Excel workbook contains a macro doesn't guarantee that the macro will ever be executed. It all depends on the security setting and whether the user chooses to enable or disable macros for that file.
To work with this book, you need to enable macros for the files you work with. My advice is to use the second security level. Then, when you open a file you've created, you can simply enable the macros. If you open a file from someone you don't know, you should disable the macros and check the VBA code to ensure that it doesn't contain anything destructive or malicious. Usually, it's pretty easy to identify suspicious VBA code.
Another option is to designate a trusted folder. Choose File?????Options?????Trust Center?????Trust Center Settings. Select the Trusted Locations option and then designate a particular folder as a trusted location. Store your trusted workbooks there, and Excel won't bug you about enabling macros. For example, if you download the sample files for this book, you can put them in a trusted location.
People who write books usually have a target reader in mind. The following points more or less describe the hypothetical target reader for this book:
Throughout this book, icons in the margins highlight certain types of valuable information that call out for your attention. Here are the icons you'll encounter and a brief description of each.
The Tip icon marks tips and shortcuts that can save you a great deal of time (and maybe even allow you to leave the office at a reasonable hour).
Remember icons mark the information that's...
Dateiformat: ePUBKopierschutz: Adobe-DRM (Digital Rights Management)
Systemvoraussetzungen:
Das Dateiformat ePUB ist sehr gut für Romane und Sachbücher geeignet – also für „fließenden” Text ohne komplexes Layout. Bei E-Readern oder Smartphones passt sich der Zeilen- und Seitenumbruch automatisch den kleinen Displays an. Mit Adobe-DRM wird hier ein „harter” Kopierschutz verwendet. Wenn die notwendigen Voraussetzungen nicht vorliegen, können Sie das E-Book leider nicht öffnen. Daher müssen Sie bereits vor dem Download Ihre Lese-Hardware vorbereiten.Bitte beachten Sie: Wir empfehlen Ihnen unbedingt nach Installation der Lese-Software diese mit Ihrer persönlichen Adobe-ID zu autorisieren!
Weitere Informationen finden Sie in unserer E-Book Hilfe.