Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Jason Jay

Rating No ratings yet

Shows how to create macros and then write vba (visual basic for applications) code. At the end of each chapter gives a short test review to make sure you remember what you read. All examples are shown in code and evoked with the output.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on beginner's path into Excel automation: record a macro, read the VBA it generates, then edit that code into something Excel can't record on its own. Best for Excel users who are comfortable with spreadsheets but have never written a line of code. 【Book Arc】 - **Opening (~0%–10%)**: Sets up the environment and the mental model — enabling the Developer tab, recording a first macro, and understanding when relative references matter versus fixed ranges. - **Early (~10%–30%)**: Bridges recording and programming: opening the Visual Basic editor to inspect recorded code, trimming redundant `.Select` steps, and attaching macros to Form and ActiveX buttons. - **Middle (~30%–55%)**: Introduces real language fundamentals — variable types and their size limits, the overflow bug that teaches why declarations matter, MsgBox return values, and If/ElseIf versus Select Case. - **Late (~55%–85%)**: Moves into structure and reuse: Modules, Public vs. Private procedures, calling routines from button click handlers, and building a multi-button calculator project step by step. - **Ending (~85%–100%)**: Extends outward — macro security settings, comments, password-protecting VBA code, and interacting with other applications such as launching apps and sending Outlook email from Excel. 【Key Takeaways】 - **Macros are the on-ramp, not the destination** (Opening): Recording captures your keystrokes — including your mistakes — so the real skill is reading the generated code and rewriting it. This reframes the whole book: record to learn syntax, then edit to gain power. - **Relative references decide where a macro runs** (Opening): Without them a macro always replays on the exact cells recorded; with them it runs from the active cell, which is what makes a macro reusable across rows and sheets. - **Excel doesn't need to select a cell to write to it** (Early): Recorded code is full of `.Select` and `ActiveCell` steps that humans need but the machine doesn't; collapsing them into direct assignments like `Range("A1") = 1` is the first real optimization a beginner makes. - **Variable types are a correctness issue, not a formality** (Early/Middle): The byte-to-integer overflow example shows how a wrong declaration produces a runtime bug, while an undeclared or Variant variable trades safety for range. Choosing types affects both bugs and speed. - **Assignment order is a classic beginner trap** (Middle): Writing `Range("A2") + Range("B2") = Range("C2")` fails because the target cell must come first — the book treats this as a rule worth memorizing. - **MsgBox returns a number, which makes it a decision tool** (Middle): Button choices map to return values (Yes = 6, No = 7, Cancel = 2), so a dialog can drive If/ElseIf or Select Case branching — the foundation of user-facing prompts. - **Public vs. Private controls reach** (Middle): Public procedures can be called from anywhere and appear in the macro list; Private ones cannot be called from other parts of the code. This is the book's introduction to scope and code organization. - **Modules plus calling keep projects maintainable** (Middle/Late): Splitting addition, subtraction, division, and multiplication into separate modules and invoking them from button handlers is the book's first lesson in structuring a program rather than piling code into one sheet. 【Reading Tips】 - **Do the quizzes and exercises rather than reading past them.** Each chapter ends with a short review and the answers are collected at the back; the book is built as a workbook, and skimming the questions removes most of its value. - **Type every code example into Excel yourself.** The book deliberately shows code alongside its output, and several lessons (the overflow bug, the reversed assignment) only land when you reproduce the error. - **Deep-read the variable-type table and the bug explanations; skim the step-by-step UI click paths** (ribbon customization, button insertion) once you've done them a single time. - **Treat the calculator project as the checkpoint.** If you can build the buttons, modules, and calling structure without following along line by line, you've absorbed the core of the book. - **Expect the later material on security, passwords, and other-application integration to be lighter** — read it for awareness rather than mastery. 【Coverage Limits】 This guide is based on stratified excerpts covering the table of contents, the opening chapters, and the middle sections on variables, MsgBox, conditionals, and modules; the excerpts do not cover the full calculator code, the macro security and password chapters, or the Outlook/other-application material in detail, so those sections are described only at the level their headings indicate.
Page 6
is time to learn the strongest functionality it has, Visual Basic for Applications (VBA). Visual Basic for Applications is a programming language incorporate...
View in text
Page 15
References Button 5. How to save a workbook with Macros? a) Just save the file normally, the Macros will be saved. b) You’ll get a notification, in which we...
View in text
Excerpt 3
and press the button. Congrats! You’ve found your first bug! It is an overflow. Bugs are errors when one writes a wrong code. In our example the code works f...
View in text
Excerpt 4
X Case Else MsgBox "There's another value" End Select End Sub This last one occupies much less code. It was easier and better. You can do practically the sam...
View in text
Excerpt 5
ption = Display.Caption + cmd1.Caption Maybe you got it now. It is exactly what we did almost in the beginning of this book. Do you remember when we make cel...
View in text
Excerpt 6
, execute the code between: Private Sub Workbook_Open() End Sub 4. Now, between those code lines, insert the following: Private Sub Workbook_Open() Calculato...
View in text
Excerpt 7
you do that, you should see the number one underlined. 6. When you see something underlined like that, not only in Excel but in all Microsoft Operating Syste...
View in text
Excerpt 8
n the Macro Button 5. How to save a workbook with Macros? a) It means that it can be called and executed from any part of the Workbook Answers Chapter 5 What...
View in text
Tags
AI categories
Programming LanguageSoftwareEducation
Publish Year: 2017
Language: English
Pages: 106
File Format: PDF
File Size: 1.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…