100% found this document useful (9 votes)
56 views

Full Download (Ebook PDF) VBA For Modelers Developing Decision Support Systems 5th PDF

Systems

Uploaded by

nasijarostja
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
100% found this document useful (9 votes)
56 views

Full Download (Ebook PDF) VBA For Modelers Developing Decision Support Systems 5th PDF

Systems

Uploaded by

nasijarostja
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/ 41

Download the full version of the ebook now at ebooksecure.

com

(eBook PDF) VBA for Modelers Developing


Decision Support Systems 5th

https://ebooksecure.com/product/ebook-pdf-vba-for-
modelers-developing-decision-support-systems-5th/

Explore and download more ebook at https://ebooksecure.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

(eBook PDF) Analytics, Data Science, & Artificial


Intelligence: Systems for Decision Support 11th Edition

https://ebooksecure.com/product/ebook-pdf-analytics-data-science-
artificial-intelligence-systems-for-decision-support-11th-edition/

ebooksecure.com

Analytics, data science, & artificial intelligence :


systems for decision support Eleventh Edition Dursun Delen
- eBook PDF
https://ebooksecure.com/download/analytics-data-science-artificial-
intelligence-systems-for-decision-support-ebook-pdf/

ebooksecure.com

(eBook PDF) Exploring VBA for Microsoft Office 2016 Brief

https://ebooksecure.com/product/ebook-pdf-exploring-vba-for-microsoft-
office-2016-brief/

ebooksecure.com

Endosonography 4th Edition Edition Robert H. Hawes - eBook


PDF

https://ebooksecure.com/download/endosonography-ebook-pdf/

ebooksecure.com
Boundary value problems for systems of differential,
difference and fractional equations : positive solutions
1st Edition Johnny Henderson - eBook PDF
https://ebooksecure.com/download/boundary-value-problems-for-systems-
of-differential-difference-and-fractional-equations-positive-
solutions-ebook-pdf/
ebooksecure.com

(eBook PDF) CompTIA Security+ Guide to Network Security


Fundamentals 6th Edition

https://ebooksecure.com/product/ebook-pdf-comptia-security-guide-to-
network-security-fundamentals-6th-edition/

ebooksecure.com

Purchasing and supply chain management Seventh Edition


Arjan J. Weele - eBook PDF

https://ebooksecure.com/download/purchasing-and-supply-chain-
management-ebook-pdf/

ebooksecure.com

Diagnostic Imaging: Gynecology 3rd Edition Akram M.


Shaaban - eBook PDF

https://ebooksecure.com/download/diagnostic-imaging-gynecology-ebook-
pdf/

ebooksecure.com

(eBook PDF) College Study The Essential Ingredients 3rd


Edition

https://ebooksecure.com/product/ebook-pdf-college-study-the-essential-
ingredients-3rd-edition/

ebooksecure.com
(eBook PDF) Health Education: Elementary and Middle School
Applications 9th Edition

https://ebooksecure.com/product/ebook-pdf-health-education-elementary-
and-middle-school-applications-9th-edition/

ebooksecure.com
About the Author

S. Christian Albright
Chris Albright got his B.S. degree in Mathematics from Stanford in 1968 and his
Ph.D. degree in Operations Research from Stanford in 1972. Until his retirement
in 2011, he taught in the Operations & Decision Technologies Department in
the Kelley School of Business at Indiana University. His teaching included courses
in management science, computer simulation, and statistics to all levels of busi-
ness students: undergraduates, MBAs, and doctoral students. He has published
over 20 articles in leading operations research journals in the area of applied
probability and he has authored several books, including Practical Management
Science, Data Analysis and Decision Making, Data Analysis for Managers, Spread-
sheet Modeling and Applications, and VBA for Modelers. He jointly developed
StatTools, a statistical add-in for Excel, with the Palisade Corporation. In “retire-
ment,” he continues to revise his books, he works as a consultant for Palisade,
and he has developed a commercial product, Excel Now!, an Excel tutorial.
On the personal side, Chris has been married to his wonderful wife Mary for
43 years. They have a special family in Philadelphia: their son Sam, his wife Lindsay,
and their two sons, Teddy and Archer. Chris has many interests outside the aca-
demic area. They include activities with his family (especially traveling with Mary),
going to cultural events at Indiana University, power walking, and reading. And
although he earns his livelihood from statistics and management science, his real
passion is for playing classical music on the piano.

vi

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents

Preface xvi

PART I VBA Fundamentals 1

1 Introduction to VBA Development in Excel 3


1.1 Introduction 3
1.2 VBA in Excel 2007 and Later Versions 4
1.3 Example Applications 5
1.4 Decision Support Systems 7
1.5 Required Background 7
1.6 Visual Basic Versus VBA 8
1.7 Some Basic Terminology 9
1.8 Summary 9

2 The Excel Object Model 10


2.1 Introduction 10
2.2 Objects, Properties, Methods, and Events 10
2.3 Collections as Objects 11
2.4 The Hierarchy of Objects 12
2.5 Object Models in General 13
2.6 Summary 17

3 The Visual Basic Editor 18


3.1 Introduction 18
3.2 Important Features of the VBE 18
3.3 The Object Browser 22
3.4 The Immediate and Watch Windows 23
3.5 A First Program 24
3.6 Intellisense 29
3.7 Color Coding and Case 30
3.8 Finding Subs in the VBE 31
3.9 Summary 33

vii

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii Contents

4 Recording Macros 35
4.1 Introduction 35
4.2 How to Record a Macro 35
4.3 Changes from Excel 2007 to Later Versions 37
4.4 Recorded Macro Examples 37
4.5 Summary 47

5 Getting Started with VBA 49


5.1 Introduction 49
5.2 Subroutines 49
5.3 Declaring Variables and Constants 50
5.4 Built-in Constants 58
5.5 Input Boxes and Message Boxes 59
5.6 Message Boxes with Yes and No Buttons 61
5.7 Using Excel Functions in VBA 63
5.8 Comments 64
5.9 Indenting 65
5.10 Strings 66
5.11 Specifying Objects, Properties, and Methods 70
5.12 With Construction 73
5.13 Other Useful VBA Tips 74
5.14 Good Programming Practices 76
5.15 Debugging 78
5.16 Summary 85

6 Working with Ranges 89


6.1 Introduction 89
6.2 Exercise 89
6.3 Important Properties and Methods of Ranges 91
6.4 Referencing Ranges with VBA 94
6.5 Examples of Ranges with VBA 97
6.6 Range Names and Their Scope 111
6.7 Summary 114

7 Control Logic and Loops 117


7.1 Introduction 117
7.2 Exercise 117
7.3 If Constructions 120
7.4 Case Constructions 126
7.5 For Loops 129
7.6 For Each Loops 136
7.7 Do Loops 138
7.8 Summary 143

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents ix

8 Working with Other Excel Objects 149


8.1 Introduction 149
8.2 Exercise 149
8.3 Collections and Members of Collections 151
8.4 Examples of Workbooks in VBA 153
8.5 Examples of Worksheets in VBA 157
8.6 Examples of Charts in VBA 163
8.7 Summary 174

9 Arrays 177
9.1 Introduction 177
9.2 Exercise 177
9.3 The Need for Arrays 179
9.4 Rules for Working with Arrays 180
9.5 Examples of Arrays in VBA 183
9.6 Array Functions 199
9.7 Summary 199

10 More on Variables and Subroutines 204


10.1 Introduction 204
10.2 Exercise 204
10.3 Scope of Variables and Subroutines 207
10.4 Modularizing Programs 209
10.5 Passing Arguments 213
10.6 Function Subroutines 219
10.7 The Workbook_Open Event Handler 225
10.8 Summary 226

11 User Forms 231


11.1 Introduction 231
11.2 Exercise 231
11.3 Designing User Forms 234
11.4 Setting Properties of Controls 238
11.5 Creating a User Form Template 242
11.6 Writing Event Handlers 243
11.7 Looping Through the Controls on a User Form 254
11.8 Working with List Boxes 255
11.9 Modal and Modeless Forms 256
11.10 Working with Excel Controls 258
11.11 Summary 262

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x Contents

12 Error Handling 268


12.1 Introduction 268
12.2 Error Handling with On Error Statement 268
12.3 Handling Inappropriate User Inputs 270
12.4 Summary 272

13 Working with Files and Folders 275


13.1 Introduction 275
13.2 Exercise 275
13.3 Dialog Boxes for File Operations 277
13.4 The FileSystemObject Object 283
13.5 A File Renaming Example 286
13.6 Working with Text Files 289
13.7 Summary 293

14 Importing Data into Excel from a Database 295


14.1 Introduction 295
14.2 Exercise 295
14.3 A Brief Introduction to Relational Databases 297
14.4 A Brief Introduction to SQL 302
14.5 ActiveX Data Objects (ADO) 306
14.6 Discussion of the Sales Orders Exercise 311
14.7 Summary 315

15 Working with Pivot Tables and Tables 317


15.1 Introduction 317
15.2 Working with Pivot Tables Manually 317
15.3 Working with Pivot Tables Using VBA 327
15.4 An Example 329
15.5 PowerPivot and the Data Model 335
15.6 Working with Excel Tables Manually 337
15.7 Working with Excel Tables with VBA 340
15.8 Summary 344

16 Working with Ribbons, Toolbars, and Menus 346


16.1 Introduction 346
16.2 Customizing Ribbons 347
16.3 Using RibbonX and XML to Customize Ribbons 348
16.4 Using RibbonX to Customize the QAT 354
16.5 CommandBar and Related Office Objects 356
16.6 A Grading Program Example 357
16.7 Summary 358

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents xi

17 Automating Solver and Other Applications 360


17.1 Introduction 360
17.2 Exercise 361
17.3 Automating Solver with VBA 363
17.4 Possible Solver Problems 373
17.5 Programming with Risk Solver Platform 375
17.6 Automating @RISK with VBA 378
17.7 Automating Other Office Applications with VBA 383
17.8 Summary 389

18 User-Defined Types, Enumerations, Collections,


and Classes 393
18.1 Introduction 393
18.2 User-Defined Types 393
18.3 Enumerations 395
18.4 Collections 396
18.5 Classes 399
18.6 Summary 406

PART II VBA Management Science Applications 409

19 Basic Ideas for Application Development with VBA 411


19.1 Introduction 411
19.2 Guidelines for Application Development 411
19.3 A Car Loan Application 416
19.4 Summary 435

20 A Blending Application 437


20.1 Introduction 437
20.2 Functionality of the Application 437
20.3 Running the Application 438
20.4 Setting Up the Excel Sheets 445
20.5 Getting Started with the VBA 445
20.6 The User Forms 447
20.7 The Module 451
20.8 Summary 452

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii Contents

21 A Product Mix Application 454


21.1 Introduction 454
21.2 Functionality of the Application 455
21.3 Running the Application 455
21.4 Setting Up the Excel Sheets 458
21.5 Getting Started with the VBA 458
21.6 The User Form 459
21.7 The Module 461
21.8 Summary 471

22 A Worker Scheduling Application 475


22.1 Introduction 475
22.2 Functionality of the Application 475
22.3 Running the Application 476
22.4 Setting Up the Excel Sheets 479
22.5 Getting Started with the VBA 480
22.6 The User Form 481
22.7 The Module 484
22.8 Summary 486

23 A Production-Planning Application 488


23.1 Introduction 488
23.2 Functionality of the Application 488
23.3 Running the Application 489
23.4 Setting Up the Excel Sheets 496
23.5 Getting Started with the VBA 498
23.6 The User Forms 499
23.7 The Module 504
23.8 Summary 511

24 A Transportation Application 513


24.1 Introduction 513
24.2 Functionality of the Application 514
24.3 Running the Application 514
24.4 Setting Up the Access Database 516
24.5 Setting Up the Excel Sheets 519
24.6 Getting Started with the VBA 519
24.7 The User Form 521
24.8 The Module 523
24.9 Summary 531

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents xiii

25 A Stock-Trading Simulation Application 534


25.1 Introduction 534
25.2 Functionality of the Application 535
25.3 Running the Application 535
25.4 Setting Up the Excel Sheets 538
25.5 Getting Started with the VBA 540
25.6 The Module 541
25.7 Summary 546

26 A Capital Budgeting Application 548


26.1 Introduction 548
26.2 Functionality of the Application 549
26.3 Running the Application 549
26.4 Setting Up the Excel Sheets 551
26.5 Getting Started with the VBA 553
26.6 The User Form 554
26.7 The Module 555
26.8 Summary 560

27 A Regression Application 562


27.1 Introduction 562
27.2 Functionality of the Application 562
27.3 Running the Application 563
27.4 Setting Up the Excel Sheets 565
27.5 Getting Started with the VBA 566
27.6 The User Form 567
27.7 The Module 569
27.8 Summary 574

28 An Exponential Utility Application 576


28.1 Introduction 576
28.2 Functionality of the Application 577
28.3 Running the Application 577
28.4 Setting Up the Excel Sheets 578
28.5 Getting Started with the VBA 582
28.6 The User Form 582
28.7 The Module 585
28.8 Summary 589

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv Contents

29 A Queueing Simulation Application 590


29.1 Introduction 590
29.2 Functionality of the Application 591
29.3 Running the Application 591
29.4 Setting Up the Excel Sheets 593
29.5 Getting Started with the VBA 593
29.6 Structure of a Queueing Simulation 594
29.7 The Module 596
29.8 Summary 606

30 An Option-Pricing Application 608


30.1 Introduction 608
30.2 Functionality of the Application 609
30.3 Running the Application 609
30.4 Setting Up the Excel Sheets 612
30.5 Getting Started with the VBA 615
30.6 The User Form 616
30.7 The Module 621
30.8 Summary 632

31 An Application for Finding Betas of Stocks 634


31.1 Introduction 634
31.2 Functionality of the Application 634
31.3 Running the Application 635
31.4 Setting Up the Excel Sheets 638
31.5 Getting Started with the VBA 639
31.6 The User Form 640
31.7 The Module 644
31.8 Summary 651

32 A Portfolio Optimization Application 653


32.1 Introduction 653
32.2 Functionality of the Application 654
32.3 Running the Application 654
32.4 Web Queries in Excel 659
32.5 Setting Up the Excel Sheets 661
32.6 Getting Started with the VBA 662
32.7 The User Forms 663
32.8 The Module 667
32.9 Summary 678

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Visit https://testbankfan.com
now to explore a rich
collection of testbank or
solution manual and enjoy
exciting offers!
Contents xv

33 A Data Envelopment Analysis Application 680


33.1 Introduction 680
33.2 Functionality of the Application 680
33.3 Running the Application 681
33.4 Setting Up the Excel Sheets and the Text File 682
33.5 Getting Started with the VBA 684
33.6 Getting Data from a Text File 685
33.7 The Module 686
33.8 Summary 698

34 An AHP Application for Choosing a Job


You can access chapter 34 at our website, www.CengageBrain.com

35 A Poker Simulation Application


You can access chapter 35 at our website, www.CengageBrain.com

Index 700

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface
I wrote VBA for Modelers for students and professionals who want to create deci-
sion support systems (DSSs) using Microsoft Excel–based spreadsheet models. The
book does not assume any prior programming experience. It contains two parts.
Part I covers the essentials of VBA (Visual Basic for Applications) programming,
and Part II provides many applications with their associated programming code.
This part assumes that readers are either familiar with spreadsheet modeling or are
taking a concurrent course in management science or operations research. There
are many excellent books available for VBA programming, many others covering
decision support systems, and still others for spreadsheet modeling. However, I
have not found a book that attempts to unify these subjects in a practical way.
VBA for Modelers is designed for this purpose, and I hope you will find it to be an
important resource and reference in your own work.

Why This Book?


The original impetus for this book began about 20 years ago. Wayne Winston
and I were experimenting with the spreadsheet approach to teaching management
as we were writing the first edition of our Practical Management Science (PMS)
book. Because I have always had an interest in computer programming, I decided
to learn VBA, the relatively new macro language for Excel, and use it to a limited
extent in my undergraduate management science modeling course. My intent was
to teach the students how to wrap a given spreadsheet model, such as a product
mix model, into an application with a “front end” and a “back end” by using
VBA. The front end would enable a user to provide inputs to the model, usually
through one or more dialog boxes, and the back end would present the user with
a nontechnical report of the results. I found it to be an exciting addition to the
usual modeling course, and my students overwhelmingly agreed.
The primary problem with teaching this type of course was the lack of an
appropriate VBA textbook. Although there are many good VBA trade books
available, they usually go into much more technical VBA details than I have time
to cover, and their objective is usually to teach VBA programming as an end in
itself. I expect that many adopters of our Practical Management Science book
will decide to use parts of VBA for Modelers to supplement their management sci-
ence courses, just as I have been doing. For readers who have already taken a
management science course, there is more than enough material in this book to
fill an entire elective course or to be used for self-study.
However, even for readers with no background or interest in management
science, the first part of this book has plenty of value. We are seeing an increasing
xvi

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xvii

number of our business students and graduates express interest in automating


Excel with macros. In short, they want to become Excel “power users.” After
the first edition of this book appeared, I taught a purely elective MBA course cov-
ering the first part of the book. To my surprise and delight, it regularly attracted
about 40 MBA students per year. Yes, it attracted MBA students, not computer
science majors! (Since I have retired from teaching, the VBA course is still being
taught, and it continues to attract these types of audiences.). The students see real
value in knowing how to program for Excel. And it is amazing and gratifying to
see how far these students can progress in a short 7-week course. Many find pro-
gramming, especially for Excel, to be as addictive as I find it.

Objectives of the Book


VBA for Modelers shows how the power of spreadsheet modeling can be
extended to the masses. Through VBA, complex management science models
can be made accessible to nontechnical users by providing them with simplified
input screens and output reports. The book illustrates, in complete detail, how
such applications can be developed for a wide variety of business problems. In
writing the book, I have always concerned myself with the following questions:
How much will readers be able to do on their own? Is it enough for readers to
see the completed applications, marvel at how powerful they are, and possibly
take a look at the code that runs in the background? Or should they be taken to
the point where they can develop their own applications, code and all? I suspect
this depends on the audience, but I know I can get students to the point where
they can develop modest but useful applications on their own and, importantly,
experience the thrill of programming success.
With these thoughts in mind, I have written this book so that it can be used
at several levels. For readers who want to learn VBA from scratch and then apply
it, I have provided a “VBA primer” in Part I of the book. It is admittedly not as
complete as some of the thick Excel VBA books available, but I believe it covers
the basics of VBA quite adequately. Importantly, it covers coding methods for
working with Excel ranges in Chapter 6 and uses these methods extensively in
later chapters, so that readers will not have to use trial and error or wade through
online help, as I had to do when I was learning VBA. Readers can then proceed to
the applications in Chapters 19 through 35 and apply their skills. In contrast, there
are probably many readers who do not have time to learn all of the details, but they
can still use the applications in Part II of the book for demonstration purposes.
Indeed, the applications have been developed for generality. For example, the
transportation model in Chapter 24 is perfectly general and can be used to solve
any transportation model by supplying the appropriate input data.

Approach
I like to teach (and learn) through examples. I have found that I can learn a pro-
gramming language only if I have a strong motivation to learn it. I suspect that

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xviii Preface

most of you are the same. The applications in the latter chapters are based on
many interesting management science models. They provide the motivation for
you to learn the material. The examples illustrate that this book is not about pro-
gramming for the sake of programming. Instead, it is about developing useful
applications for business. You probably already realize that Excel modeling skills
make you more valuable in the workplace. This book will help you develop VBA
skills that make you much more valuable.

Contents of the Book


The book is written in two parts. Part I, Chapters 1–18, is a VBA primer for read-
ers with little or no programming experience in VBA (or any other language).
Although all of these chapters are geared to VBA, some are more about general
programming concepts, whereas others deal with the unique aspects of program-
ming for Excel. Specifically, Chapters 7, 9, and 10 discuss control logic (If-Then-
Else constructions), loops, arrays, and subroutines, topics that are common to all
programming languages. In contrast, Chapters 6 and 8 explain how to work with
some of the most common Excel objects (ranges, workbooks, worksheets, and
charts) in VBA. In addition, several chapters discuss aspects of VBA that can be
used with Excel and any other applications (Access, Word, PowerPoint, and so
on) that use VBA as their programming language. Specifically, Chapter 3 explains
the Visual Basic Editor (VBE), Chapter 4 illustrates how to record macros,
Chapter 11 explains how to build user forms (dialog boxes), and Chapter 12
discusses the important topic of error handling.
The material in Part I is reasonably complete, but it is available, in greater
detail and with a somewhat different emphasis, in several other books. The
unique aspect of this book is Part II, Chapters 19–35. (Due to length, the
last two chapters, Chapter 34, An AHP Application for Choosing a Job, and
Chapter 35, A Poker Simulation Application, are available online only. You can
find them at www.CengageBrain.com.) Each chapter in this part discusses a specific
application. Most of these are optimization and simulation applications, and many
are quite general. For example, Chapter 21 discusses a general product mix applica-
tion, Chapter 23 discusses a general production scheduling application, Chapter 24
discusses a general transportation application, Chapter 25 discusses a stock-trading
simulation, Chapter 29 discusses a multiple-server queue simulation, Chapter 30
discusses a general application for pricing European and American options, and
Chapter 32 discusses a general portfolio optimization application. (Many of the
underlying models for these applications are discussed in Practical Management
Science, but I have attempted to make these applications stand-alone here.)
The applications can be used as they stand to solve real problems, or they
can be used as examples of VBA application development. All of the steps in
the development of these applications are explained, and all of the VBA source
code is included. Using an analogy to a car, you can simply get in and drive, or
you can open the hood and see how everything works.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xix

Chapter 19 gets the process started in a “gentle” way. It provides a general


introduction to application development, with an important list of guidelines. It
then illustrates these guidelines in a car loan application. This application should
be within the grasp of most readers, even if they are not yet great programmers.
By tackling this application first, readers get to develop a simple model, with
dialog boxes, reports, and charts, and then tie everything together. This car loan
application illustrates an important concept that I stress throughout the book.
Specifically, applications that really do something are often long and have a lot of
details. But this does not mean that they are difficult. With perseverance—a word
I use frequently—readers can fill in the details one step at a time and ultimately
experience the thrill of getting a program to work correctly.
Virtually all management science applications require input data. A very
important issue for VBA application development is how to get the required
input data into the spreadsheet model. I illustrate a number of possibilities in
Part II. If only a small amount of data is required, dialog boxes work well. These
are used for data input in many of the applications. However, there are many
times when the data requirements are much too large for dialog boxes. In these
cases, the data are usually stored in some type of database. I illustrate some com-
mon possibilities. In Chapter 21, the input data for a product mix model are
stored in a separate worksheet. In Chapter 31, the stock price data for finding
the betas of stocks are stored in a separate Excel workbook. In Chapter 33, the
data for a DEA model are stored in a text (.txt) file. In Chapter 24, the data for a
transportation model are stored in an Access database (.mdb) file. Finally, in Chap-
ter 32, the stock price data required for a portfolio optimization model are located
on a Web site and are imported into Excel, at runtime. In each case, I explain the
VBA code that is necessary to import the data into the Excel application.

New to the Fifth Edition


The impetus for writing the fifth edition was the release of Excel 2013. In terms
of VBA, there aren’t many changes from Excel 2010 to Excel 2013 (or even from
Excel 2007 to Excel 2013), but I used the opportunity to incorporate changes
that were made in Excel 2013, as well as to modify a lot of the material
throughout the book.
● Programmers can never let well enough alone. We are forever tinkering with
our code, not just to make it work better, but often to make it more elegant
and easier to understand. So users of previous editions will see minor changes
to much of the code throughout the book.
● The biggest change, which has nothing to do with the version of Excel, is the
way information is passed between modules and user forms. In previous edi-
tions, I did this with global variables, a practice frowned upon by many pro-
fessional programmers. In this edition, I pass the required information
through arguments to “ShowDialog” functions in the user forms. This new
method is explained in detail in Chapter 11 and is then used in later chapters
where user forms appear.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Exploring the Variety of Random
Documents with Different Content
have taken the food out of it. Much of this water passes out through
the leaves.
You know when you are very warm, you feel a moisture come on
your skin. That was once water in your blood. It creeps out through
tiny pores over all your skin.
The plant skin has such pores. The water goes off through them.
When the plant breathes out this water, then more hurries up through
the cells to take its place. So the sap keeps running up and down all
the time.
Plants not only send out water through the pores of the leaves, but
also a kind of air or gas. If they did not do that, we should soon all be
dead. Can I make that plain to you?
Did you ever hear your mother say, “The air here is bad or close”?
Did you ever see your teacher open a door or a window, to “air” the
schoolroom? If you ask why, you will be told “So many people
breathing here make the air bad.”
How does our breathing make the air bad? When our blood runs
through our bodies it takes up little bits of matter that our bodies are
done with. This stuff makes the blood dark and thick. But soon the
blood comes around to our lungs.
Now as we breathe out, we send into the air the tiny atoms of this
waste stuff. It is carbonic acid gas. As we breathe in, we take from
the fresh air a gas called oxygen. That goes to our lungs, and lo! it
makes the blood fresh and clean, and red once more.
So you can see, that when many people breathe in one room they
will use up all the good clean air. At the same time they will load the
air of the room with the gas they breathe out.
That is why the window is opened. We wish to sweep away the bad
air, and let in good air.
But at this rate, as all men and other animals breathe out carbonic
acid gas, why does not all the air in the world get bad? Why, when
they all use oxygen, do they not use up all the oxygen that is in the
world?
Just here the plants come in to help. Carbonic acid gas is bad for
men, it is food to plants. Oxygen is needed by animals, but plants
want to get rid of it. Animals breathe out a form of carbon and
breathe in oxygen. Plants do just the other thing. They breathe out
oxygen and take in carbonic acid gas.
The air, loaded with this, comes to the plant. At once all the little leaf-
mouths are wide open to snatch out of the air the carbonic acid gas.
And, as the plants are very honest little things, they give where they
take away. They take carbon from the air, and breathe into the air a
little oxygen.
Where did they get that? The air they breathe has both carbon and
oxygen in it. So they keep what they want,—that is, carbon,—and
send out the oxygen.
Now it is only the green part of the plant that does this fine work for
us. It is the green parts, chiefly the leaves, that send out good
oxygen for us to breathe. It is the green leaf that snatches from the
air those gases which would hurt us.
It is the green leaf that changes the harmful form of carbon into good
plant stuff, which is fit for our food. How does it do that? Let us see.
What makes a leaf green? Bobby who crushed a leaf to see, told me
“a leaf was full of green paint.”
Inside the green leaves is a kind of green paste, or jelly. Now it is this
“leaf-green” that does all the work. The “leaf-green” eats up carbon.
The “leaf-green” turns carbon into nice safe plant material. It is “leaf-
green” that sets free good oxygen for us.
“Leaf-green” is a good fairy, living in every little cell in the leaf. Leaf-
green is a fairy which works only in the day-time. Leaf-green likes
the sun. Leaf-green will not work in the dark, but goes to bed and
goes to sleep!
In such simple lessons as these, I can tell you only a little of what is.
The deep “how” and “why” of things I cannot explain. Even the very
wisest men do not know all the how and the why of the “leaf-green”
fairy.
I have told you these few things that you may have wonders to think
of when you see green leaves. After this lesson, will you not care
more for seeds and leaves than you ever did before?
LESSON VIII.
THE COLOR OF PLANTS.
Almost the first thing that you will notice about a plant is its color. The
little child, before it can speak, will hold out its hands for a bright red
rose, or a golden lily. I think the color is one of the most wonderful
things about a plant.
Come into the field. Here you see a yellow buttercup, growing near a
white daisy. Beside them is a red rose. Close by, blooms a great
purple flower. All grow out of the same earth, and breathe the same
air. Yet how they differ in color.
Some flowers have two or three colors upon each petal. Have you
not seen the tulip with its striped blossoms, and the petunias spotted
with white and red?
The flower of the cotton plant changes in color. Within a few days
this flower appears in three distinct hues. The chicory blossom
changes from blue to nearly white as the day grows warm.
Look at your mother’s roses. Some are white, others are red, pink, or
yellow. None are ever blue.
Then look at a wild-rose tree. The root and stem are brown. The
green color is in the leaves, and in some of the stems. The petals
are red. The stamens and pistils are yellow.
You never saw the red color get astray and run into the leaves. The
leaf-green did not lose itself, and travel up to the petals. The
stamens and pistils did not turn brown instead of golden.
Does not that seem a wonder, now that you think of it? Perhaps you
never noticed it before. It is one thing to see things, and another to
notice them so that you think about them.
Here is another fact about color in plants. All summer you see that
the leaves are green. In the autumn they begin to change. You wake
up some fine frosty morning and the tree leaves are all turned red,
yellow, brown, or purple. It is a fine sight.
It is the going away of the leaf-green from the leaf that begins the
change of leaf-color in the fall. The leaves have done growing. Their
stems are hard and woody. They do not breathe as freely as they
did. The sap does not run through them as it did early in the season.
The leaf-green shrinks up in the cells. Or, it goes off to some other
part of the plant. Sometimes part of it is destroyed. Then the leaves
begin to change.
Sometimes a red sap runs into the leaf cells. Or, an oily matter goes
there, in place of the “leaf-green.”
The leaf-green changes color if it gets too much oxygen. In the
autumn the plant does not throw out so much oxygen. What it keeps
turns the leaf-green from green to red, yellow, or brown.
The bright color in plants is not in the flower alone. You have seen
that roots and seeds have quite as bright colors as blossoms. What
flowers are brighter than many fruits are?
The cherry is crimson, or pink, or nearly black. What a fine yellow,
red, purple, we find in plums! Is there any yellow brighter than that of
the Indian corn? Is there a red gayer than you find on the apples you
like so well? What is more golden than a heap of oranges?
If you wish to find splendid color in a part of a plant, look at a water-
melon. The skin is green marked with pale green, or white. Next,
inside, is a rind of pale greenish white. Then comes a soft, juicy,
crimson mass. In that are jet black seeds.
Oh, where does all this color come from? Why is it always just in the
right place? The melon rind does not take the black tint that belongs
to the seeds. The skin does not put on the crimson of the pulp. See,
too, how this color comes slowly, as the melon ripens. At first the
skin is of the same dark green as the leaves, and inside all is of a
greenish white.
Let us try to find out where all this color comes from. Do you know
we ourselves can make changes in the color of flowers? Take one of
those big hydrangeas. It has a pink flower. But give it very rich black
earth to grow in. Mix some alum and iron with the earth. Water it with
strong bluing water. Lay soot and coal-dust upon the earth it grows
in. Very soon your hydrangea will have blue flowers, instead of pink
ones.
Once I had a petunia with large flowers of a dirty white color. I fed it
with soot and coal-dust. I watered it with strong bluing water. After a
few weeks my petunia had red or crimson flowers. Some of the
flowers were of a very deep red. Others were spotted with red and
white.
Now from this you may guess that the plant obtains much of its color
from what it feeds on in the soil.
But you may give the plant very good soil, and yet if you make it
grow in the dark, it will have almost no color. If it lives at all, even the
green leaves will be pale and sickly.
This will show you that the light must act in some way on what the
plant eats, to make the fine color.
The plant, you know, eats minerals from the earth. In its food it gets
little grains of coloring stuff.
But how the color goes to the right place we cannot tell. We cannot
tell why it is, that from the same earth, in the same light, there will be
flowers of many colors. We cannot tell why flowers on the same
plant, or parts of the same flower, will have different colors. That is
one of the secrets and wonders that no one has found out.
There are many plants which store up coloring matter, just as plants
store up starch, or sugar. The indigo, which makes our best blue
dye, comes from a plant. Ask your mother to show you some indigo.
When the plant is soaked in water the coloring stuff sinks to the
bottom of the water, like a blue dust.
Did you ever notice the fine red sumac? That gives a deep yellow
dye. The saffron plant is full of a bright orange color. Other plants
give other dyes.
Sometimes children take the bright petals of plants, or stems, that
have bright color in them, to paint with. Did you ever do that? You
can first draw a picture, and then color it, by rubbing on it the colored
parts of plants.
Some trees and plants, from which dyes are made, have the coloring
stuff in the bark or wood. That is the way with the logwood tree. The
best black dye is made from that.
You have seen how much dark red juice you can find in berries. Did
you ever squeeze out the red juice of poke or elder berries? It is like
red ink. Did you ever notice how strawberries stain your fingers red?
Grapes and blackberries make your lips and tongue purple.
No doubt you have often had your hands stained brown, for days,
from the husks of walnuts. All these facts will show you what a deal
of color is taken up from the soil by plants, changed by the sun, and
stored up in their different parts.
But the chief of all color in the plant is the leaf-green. We cannot
make a dye out of that.
Leaf-green is the color of which there is the most. It is the color
which suits the eye best of all. How tired we should be of crimson or
orange grass!
Though leaves and stems are generally green, there are some
plants which have stems of a bright red or yellow color. Yellow is the
common color for stamens and pistils. In some plants, as the tulip,
the peach, and others, the stamens are of a deep red-brown, or
crimson, or pink, or even black color.
LESSON IX.
THE MOTION OF PLANTS.
If I ask you what motion plants have, I think you will tell me that they
have a motion upward. You will say that they “grow up.” You will not
say that they move in the wind. You know that that is not the kind of
motion which I mean.
Some plants grow more by day, some by night. On the whole, there
is more growing done by day than by night. At night it is darker,
cooler, and there is more moisture in the air. The day has more heat,
light, and dryness. For these causes growth varies by day and by
night.
Warmth and moisture are the two great aids to the growth of plants.
Heat, light, and wet have most to do with the motion of plants. For
the motion of plants comes chiefly from growth.
The parts of the plant the motion of which we shall notice, are, the
stems, leaves, tendrils, and petals. Perhaps you have seen the
motion of a plant stem toward the sunshine.
Did you ever notice in house plants, that the leaves and branches
turn to the place from which light comes to them? Did you ever hear
your mother say that she must turn the window plants around, so
that they would not grow “one-sided”?
Did you ever take a pot plant that had grown all toward one side, and
turn it around, and then notice it? In two or three weeks you would
find the leaves, stems, branches, bent quite the other way. First they
lifted up straight. Then they slowly bent around to the light.
Perhaps you have noticed that many flower stems stoop to the east
in the morning. Then they move slowly around. At evening you find
them bending toward the west.
This is one motion of stems. Another motion is that of long, weak
stems, such as those of the grape-vine or morning-glory. They will
climb about a tree or stick.
Such vines do much of their climbing by curling around the thing
which supports them. If you go into the garden, and look at a bean-
vine, you will see what fine twists and curves it makes about the
beanpole.
Such twists or curves can be seen yet more plainly in a tendril. A
tendril is a little string-like part of the plant, which serves it for hands.
Sometimes tendrils grow out of the tips of the leaves.
Sometimes they grow from the stem. Sometimes they grow from the
end of a leaf-stem in place of a final leaf.
Tendrils, as I told you before, are twigs, leaves, buds, or other parts
of a plant, changed into little, long clasping hands.
Now and then the long slender stem of a leaf acts as a tendril. It
twists once around the support which holds up the vine. Thus it ties
the stem of the vine to the support.
You have seen not only climbing plants, such as the grape-vine. You
have seen also creeping plants, as the strawberry and ground-ivy.
You will tell me that a climbing plant is one which travels up
something. You will say, also, that a creeping plant is a vine which
runs along the ground.
The climbing plant helps itself along by tendrils. The creeping plant
has little new roots to hold it firm.
Look at the strawberry beds. Do you see some long sprays which
seem to tie plant to plant? Your father will tell you that they are
“runners.”
The plant throws out one of these runners. Then at the end of the
runner a little root starts out, and fastens it to the ground. A runner is
very like a tendril. There are never any leaves upon it. But the end of
a tendril never puts out a bud. The end of the runner, where it roots,
puts out a bud.
This bud grows into a new plant. The new plant sends out its
runners. These root again, and so on. Thus, you see, a few
strawberry plants will soon cover a large space of ground.
There is a very pretty little fern, called the “walking fern,” which has
an odd way of creeping about. When the slender fronds[8] reach their
full length, some of the tallest ones bend over to the earth. The tip of
the frond touches the ground. From that tip come little root-like
fibres, and fix themselves in the earth. A new plant springs up from
them.
When the new plant is grown, a frond of that bends over and takes
root again. So it goes on. Soon there is a large, soft, thick mat of
walking fern upon the ground.
This putting out new roots to go on by is also the fashion of some
climbing plants. Did you ever notice how the ivy will root all along a
wall? Little strong roots put out at the joints of the stem, and hold the
plant fast.
All this motion in plants is due to growth. In very hot lands where
there is not only much heat, but where long, wet seasons fill the
earth with water, the growth of plants is very rapid.
In these hot lands, there are more climbing plants than in cool lands.
Some trees, which, in cool lands where they grow slowly, never
climb, turn to climbers in hot lands.
Some plants will twine and climb in hot weather, and stand up
straight alone in cool weather. This shows that in hot weather they
grow so fast that they cannot hold themselves up. When it is cool,
they grow slowly, and make more strong fibre. But we must leave the
stem motions of plants and speak of the motion of other parts.
Let me tell you how to try the leaf motion of plants. Take a house
plant to try, as that is where wind will not move the leaf. Get a piece
of glass about four or five inches square. Smoke it very black.
Lay it under the leaf, so that the point of the leaf bent down will be
half an inch from the glass.
Then take a bristle from a brush and put it in the tip of the leaf. Run
the bristle in the leaf so that the end will come beyond the leaf, and
just touch the glass. Leave it a night and a day. Then you will find the
story of the leaf’s travels written on the glass. As the leaf moves, the
bristle will write little lines in the black on the glass. Try it.
As you have proved the motion of the leaf with your smoked glass,
let us look at leaf motion. There is, first, that motion which unfolds or
unrolls the leaf from the bud. That is made because, by feeding, the
plant is growing larger, and the leaf needs more room.
The leaf often has, after it is grown, a motion of opening and
shutting. Other leaves have a motion of rising and falling. But of
these motions I will tell you in another lesson.
Flowers have, first, the motion by which the flower-bud unfolds to the
full, open blossom. That, as the leaf-bud motion, comes from
growing. Did you ever watch a rose-bud, or a lily-bud, unfold?
Then the flowers of many plants have a motion of opening and
shutting each day. I shall tell you of that, also, in another lesson.
Besides these motions in plants, there are others. Did you ever see
how a plant will turn, or bend, to grow away from a stone, or
something, that is in its way?
If you watch with care the root of one of your bean-seeds, you will
see that it grows in little curves, now this way, now that. It grows so,
even when it grows in water, or in air, where nothing touches it.
People who study these changes tell us that the whole plant, as it
grows, has a turning motion. In this motion all the plant, and all its
parts, move around as they grow.
The curious reasons for this motion of plants, you must learn when
you are older. I can now tell you only a little about it. I will tell you that
the plant moves, because the little cells in it grow in a one-sided way.
Thus the air, light, heat, moisture, cause the cells on one side of the
plant to grow larger than the others. Then the plant stoops, or is
pulled over, that way. It is bent over by the weight. Then that side is
hidden, and the other side has more light, heat, and wet. And as the
cells grow, it stoops that way.
This is easy to understand in climbing plants. Their long, slim stems
are weak. They bend with their own weight. They bend to the side
that is slightly heavier. Their motion then serves to find them a
support. As they sweep around, they touch something which will hold
them up. Then they cling to it.
Now, there is another reason for a tendril taking hold of anything.
The skin of the tendril is very soft and fine. As it lies against a string,
or stick, or branch, the touch of this object on its fine skin makes the
tendril bend, or curl.
It keeps on bending or curling, until it gets quite around the object
which it touches. Then it still goes on bending, and so it gets around
a second time, and a third, and so on. Thus the tendril makes curl
after curl, as closely and evenly as you could wind a string on a stick.
Some plants, as the hop, move around with the sun; other plants
move in just the other direction. It is as if some turned their faces,
and some their backs, to the sun.

FOOTNOTES:
[8] What you call the leaf of a fern is, properly speaking, a frond.
LESSON X.
PLANTS AND THEIR PARTNERS.
Did I not tell you that the plants had taken partners and gone into
business? I said that their business was seed-growing, but that the
result of the business was to feed and clothe the world.
In our first lessons we showed you that we get all our food, clothes,
light, and fuel, first or last, from plants. “Stop! stop!” you say. “Some
of us burn coal. Coal is a mineral.” Yes, coal is a mineral now, but it
began by being a vegetable. All the coal-beds were once forests of
trees and ferns. Ask your teacher to tell you about that.
If all these things which we need come from plants, we may be very
glad that the plants have gone into business to make more plants.
Who are these partners which we told you plants have? They are the
birds and the insects. They might have a sign up, you see, “Plant,
Insect & Co., General Providers for Men.”
Do let us get at the truth of this matter at once! Do you remember
what you read about the stamens and pistils which stand in the
middle of the flower? You know the stamens carry little boxes full of
pollen. The bottom of the pistil is a little case, or box, full of seed
germs.
You know also that the pollen must creep down through the pistils,
and touch the seed germs before they can grow to be seeds. And
you also know, that unless there are new seeds each year the world
of plants would soon come to an end.
Now you see from all this that the stamens and pistils are the chief
parts of the flower. The flower can give up its calyx, or cup, and its
gay petals, its color, honey, and perfume. If it keeps its stamens and
pistils, it will still be a true seed-bearing flower.
It is now plain that the aim of
the flower must be to get
that pollen-dust safely
landed on the top of the
pistil.
You look at a lily, and you
say, “Oh! that is very easy.
Just let those pollen boxes
fly open, and their dust is
sure to hit the pistil, all right.”
But not so fast! Let me tell
you that many plants do not
carry the stamens and pistils
all in one flower. The
stamens, with the pollen
boxes, may be in one flower,
and the pistil, with its sticky
cushion to catch pollen, may
be in another flower.
More than that, these
flowers, some with stamens, THE THREE PARTNERS.
and some with pistils, may
not even be all on one plant! Have you ever seen a poplar-tree? The
poplar has its stamen-flowers on one tree, and its pistil-flowers on
another. The palm-tree is in the same case.
Now this affair of stamen and pistil and seed making does not seem
quite so easy, does it? And here is still another fact. Seeds are the
best and strongest, and most likely to produce good plants, if the
pollen comes to the pistil, from a flower not on the same plant.
This is true even of such plants as the lily, the tulip, and the
columbine, where stamens and pistils grow in one flower.
Now you see quite plainly that in some way the pollen should be
carried about. The flowers being rooted in one place cannot carry
their pollen where it should go. Who shall do it for them?
Here is where the insect comes in. Let us look at him. Insects vary
much in size. Think of the tiny ant and gnat. Then think of the great
bumble bee, or butterfly. You see this difference in size fits them to
visit little or big flowers.
You have seen the great bumble bee busy in a lily, or a trumpet
flower. Perhaps, too, you have seen a little ant, or gnat, come
crawling out of the tiny throat of the thyme or sage blossom. And you
have seen the wasp and bee, busy on the clover blossom or the
honeysuckle.
Insects have wings to take them quickly wherever they choose to go.
Even the ant, which has cast off its wings,[9] can crawl fast on its six
nimble legs.
Then, too, many insects have a long pipe, or tongue, for eating. You
have seen such a tongue on the bee.[10] In this book you will soon
read about the butterfly, with its long tube which coils up like a watch
spring.
With this long tube the insect can poke into all the slim cups, and
horns, and folds, of the flowers of varied shapes.
Is it not easy to see that when the insect flies into a flower to feed, it
may be covered with the pollen from the stamens? Did you ever
watch a bee feeding in a wild rose? You could see his velvet coat all
covered with the golden flower dust.
Why does the insect go to the flower? He does not know that he is
needed to carry pollen about. He never thinks of seed making. He
goes into the flower to get food. He eats pollen sometimes, but
mostly honey.
In business, you know, all the partners wish to make some profit for
themselves. The insect partner of the flower has honey for his gains.
The flower lays up a drop of honey for him.
In most flowers there is a little honey. Did you ever suck the sweet
drop out of a clover, or a honeysuckle? This honey gathers in the
flower about the time that the pollen is ripe in the boxes. Just at the
time that the flower needs the visit of the insects, the honey is set
ready for them.
Into the flower goes the insect for honey. As it moves about, eating,
its legs, its body, even its wings, get dusty with pollen. When it has
eaten the honey of one flower, off it goes to another. And it carries
with it the pollen grains.
As it creeps into the next flower, the pollen rubs off the insect upon
the pistil. The pistil is usually right in the insect’s way to the honey.
The top of the pistil is sticky, and it holds the pollen grains fast. So
here and there goes the insect, taking the pollen from one flower to
another.
But stop a minute. The pollen from a rose will not make the seed
germs of a lily grow. The tulip can do nothing with pollen from a
honeysuckle. The pollen of a buttercup is not wanted by any flower
but a buttercup. So of all. The pollen to do the germ any good must
come from a flower of its own kind.
What is to be done in this case? How will the insect get the pollen to
the right flower? Will it not waste the clover pollen on a daisy?
Now here comes in a very strange habit of the insect. Insects fly
“from flower to flower,” but they go from flowers of one kind to other
flowers of the same kind. Watch a bee. It goes from clover to clover,
not from clover to daisy.
Notice a butterfly. It flits here and there. But you will see it settle on a
pink, and then on another pink, and on another, and so on. If it
begins with golden rod, it keeps on with golden rod.
God has fixed this habit in insects. They feed for a long time on the
same kind of flowers. They do this, even if they have to fly far to
seek them. If I have in my garden only one petunia, the butterfly
which feeds in that will fly off over the fence to some other garden to
find another petunia. He will not stop to get honey from my sweet
peas.
Some plants have drops of honey all along up the stem to coax ants
or other creeping insects up into the flower.
But other plants have a sticky juice along the stem, to keep crawling
insects away. In certain plants the bases of the leaf-stems form little
cups, for holding water. In this water, creeping insects fall and drown.
Why is this? It is because insects that would not properly carry the
pollen to another flower, would waste it. So the plant has traps, or
sticky bars, to keep out the kind of insects that would waste the
pollen, or would eat up the honey without carrying off the pollen.
I have not had time to tell you of the many shapes of flowers. You
must notice that for yourselves.
Some are like cups, some like saucers, or plates, or bottles, or bags,
or vases. Some have long horns, some have slim tubes or throats.
Some are all curled close about the stamens and pistils.
These different kinds of flowers need different kinds of insects to get
their pollen. Some need bees with thick bodies. Some need
butterflies with long, slim tubes. Some need wasps with long, slender
bodies and legs. Some need little creeping ants, or tiny gnats.
Each kind of flower has what will coax the right kind of insects, and
keep away the wrong ones. What has the plant besides honey to
coax the insect for a visit? The flower has its lovely color, not for us,
but for insects. The sweet perfume is also for insects.
Flowers that need the visits of moths, or other insects that fly by
night, are white or pale yellow. These colors show best at night.
Flowers that need the visits of day-flying insects, are mostly red,
blue, orange, purple, scarlet.
There are some plants, as the grass, which have no sweet perfume
and no gay petals. I have told you of flowers which are only a small
brown scale with a bunch of stamens and pistils held upon it. And
they have no perfumes. These flowers want no insect partners. Their
partner is the summer wind! The wind blows the pollen of one plant
to another. That fashion suits these plants very well.
So, by means of insect or wind partners, the golden pollen is carried
far and wide, and seeds ripen.
But what about the bird partners? Where do they come in?
If the ripe seed fell just at the foot of the parent plant, and grew
there, you can see that plants would be too much crowded. They
would spread very little. Seeds must be carried from place to place.
Some light seeds, as those of the thistle, have a plume. The maple
seeds have wings. By these the wind blows them along.
But most seeds are too heavy to be wind driven. They must be
carried. For this work the plant takes its partner, the bird.
To please the eye of the bird, and attract it to the seed, the plant has
gay-colored seeds. Also it has often gay-colored seed cases. The
rose haws, you know, are vivid red. The juniper has a bright blue
berry. The smilax has a black berry. The berries of the mistletoe are
white, of the mulberry purple.
These colors catch the eye of the bird. Down he flies to swallow the
seed, case, and all. Also many seed cases, or covers, are nice food
to eat. They are nice for us. We like them. But first of all they were
spread out for the bird’s table.
Birds like cherries, plums, and strawberries. Did you ever watch a
bird picking blackberries? The thorns do not bother him. He swallows
the berries fast,—pulp and seed.
You have been told of the hard case which covers the soft or germ
part of the seed, and its seed-leaf food. This case does not melt up
in the bird’s crop or gizzard, as the soft food does. So when it falls to
the ground the germ is safe, and can sprout and grow.
Birds carry seeds in this way from land to land, as well as from field
to field. They fly over the sea and carry seeds to lonely islands,
which, but for the birds, might be barren.
So by means of its insect partners, the plant’s seed germs grow, and
perfect seeds. By means of the bird partners, the seeds are carried
from place to place. Thus many plants grow, and men are clothed,
and warmed, and fed.

FOOTNOTES:
[9] See Nature Reader, No. 2, Lessons on Ants.
[10] No. 1, Lesson 18.
LESSON XI.
AIR, WATER, AND SAND PLANTS.
Most of the plants which you see about you grow in earth or soil. You
have heard your father say that the grass in some fields was scanty
because the soil was poor. You have been told that wheat and corn
would not grow in some other field, because the soil was not rich
enough.
You understand that. The plant needs good soil, made up of many
kinds of matter. These minerals are the plant’s food. Perhaps you
have helped your mother bring rich earth from the forest, to put
about her plants.
But beside these plants growing in good earth in the usual way, there
are plants which choose quite different places in which to grow.
There are air-plants, water-plants, sand-plants. Have you seen all
these kinds of plants?
You have, no doubt, seen plants growing in very marshy, wet places,
as the rush, the iris, and the St. John’s-wort. Then, too, you have
seen plants growing right in the water, as the water-lilies, yellow and
white; the little green duck-weed; and the water crow-foot.
If you have been to the sea-shore, you have seen green, rich-looking
plants, growing in a bank of dry sand. In the West and South, you
may find fine plants growing in what seem to be drifts, or plains of
clear sand.
Air-plants are less common. Let us look at them first. There are
some plants which grow upon other plants and yet draw no food
from the plant on which they grow. Such plants put forth roots,
leaves, stems, blossoms, but all their food is drawn from the air.
I hope you may go and see some hot-house where orchids are kept.
You will see there splendid plants growing on a dead branch, or

You might also like