Tải bản đầy đủ (.pdf) (738 trang)

1674 excel for chemists, 3rd edition

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (37.79 MB, 738 trang )

Excel® for Chemists

www.it-ebooks.info


Excel®

for Chemists

A Comprehensive Guide
Third Edition

E. Joseph Billo

WILEY
A JOHN WILEY & SONS, INC., PUBLICATION

www.it-ebooks.info


Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
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
Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the
Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center,
Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at
www.copyright.com. 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) 7486008, or online at />Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in
preparing this book, they make no representations or warranties with respect to the accuracy or completeness of


the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a
particular purpose. No warranty may be created or extended by sales representatives or written sales materials.
The advice and strategies contained herein may not be suitable for your situation. You should consult with a
professional where appropriate. Neither the publisher nor author 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 or for technical support, please contact our Customer
Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax
(317)572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic formats. For more information about Wiley products, visit our web site at
www.wiley.com.
Library of Congress Cataloging-in-Publication Data:
Billo, E. Joseph.
Excel for chemists : a comprehensive guide / E. Joseph Billo. — 3rd ed.
p. cm.
Includes index.
ISBN 978-0-470-38123-6 (pbk.)
1. Electronic spreadsheets. 2. Chemistry—Data processing. 3. Microsoft Excel (Computer file) I. Title.
QD39.3.S67B55 201I
542'.85—dc22
2011010945
Printed in the United States of America.
oBook: 978-1-118-09395-5
ePDF: 978-1-118-09393-1
ePub: 978-1-118-09394-8
10 9 8 7 6 5 4 3 2 1

www.it-ebooks.info



Summary of Contents

PART I
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
PART II
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
PART III
Chapter 13
Chapter 14
Chapter 15
PART IV
Chapter 16
Chapter 17
Chapter 18
PART V
Chapter 19
Chapter 20
Chapter 21
Chapter 22
Chapter 23

PART VI
Appendix A
Appendix B
Appendix C
Appendix D
Appendix E
Appendix F
Appendix G
Appendix H
Appendix I
Appendix J
Appendix K

Contents
Preface to the Third Edition
Before You Begin
THE BASICS
Working with Excel 2007 or Excel 2010
Working with Excel 2003
Excel Formulas and Functions
Excel 2007/2010 Charts
Excel 2003 Charts
ADVANCED SPREADSHEET TOPICS
Advanced Worksheet Formulas
Array Formulas
Advanced Charting Techniques
Using Excel's Database Features
Importing Data into Excel
Adding Controls to a Spreadsheet
Other Language Versions of Excel

SPREADSHEET MATHEMATICS
Mathematical Methods for Spreadsheet Calculations
Linear Regression and Curve Fitting
Nonlinear Regression Using the Solver
EXCEL'S VISUAL BASIC FOR APPLICATIONS
Visual Basic for Applications: An Introduction
Programming with VBA
Working with Arrays in VBA
SOME APPLICATIONS OF VBA
Command Macros
Custom Functions
Automatic Procedures
Custom Menus
Custom Toolbars and Toolbuttons
APPENDICES
What's Where in Excel 2007/2010
Selected Worksheet Functions by Category
Alphabetical List of Selected Worksheet Functions
Renamed Functions in Excel 2010
Selected Visual Basic Keywords by Category
Alphabetical List of Selected Visual Basic Keywords
Selected Excel 4 Macro Functions
Shortcut Keys by Keystroke
Selected Shortcut Keys by Category
ASCII Codes
Contents of the CD-ROM
INDEX

v


www.it-ebooks.info

vii
xxv
xxvii
3
79
137
177
209
233
267
289
327
349
365
385
403
435
463
491
503
543
557
571
589
595
607

629

633
639
661
663
667
689
693
703
707
709
719


Contents
Preface to the Third Edition
Before You Begin
PART I

xxv
xxvii

THE BASICS

Chapter 2 Working with Excel 2007 or Excel 2010
What's New in Excel 2007 and Excel 2010
The Ribbon
New File Formats
A Much Larger Worksheet
Larger Limits for Some Features
New Worksheet Functions

The Downside
What's New in Excel 2010
The Excel 2007/2010 Document Window
Hiding, Moving or Resizing a Document Window
Working with Excel 2007/2010
The Office Button (Excel 2007)
The File Tab (Excel 2010)
The Excel Options Window
The Ribbon: An Overview
Shortcut Menus
Keyboard Access to the Ribbon
The Home Tab
Navigating Around the Workbook
Inserting or Deleting Worksheets
Changing the Name of a Worksheet
Rearranging the Order of Sheets in a Workbook
Selecting Multiple Worksheets: [Group] Mode
Changing the Color of Sheet Tabs
Using Move or Copy Sheet or Delete Sheet
Navigating Around the Worksheet
Selecting a Range of Cells
Selecting Non-Adjacent Ranges
Extending a Selection
Selecting a Block of Cells
Entering Data in a Worksheet
Entering Numbers
How Excel Stores and Displays Numbers

vn


www.it-ebooks.info

3
3
4
4
5
5
5
5
6
7
7
7
8
9
10
12
12
13
13
13
15
15
16
17
17
18
18
19

19
19
20
21
21


viii

Excel for Chemists

Entering Text
Entering Formulas
Editing Cell Entries
The Order in Which Excel Performs Operations in Formulas
Adding a Text Box
Entering an Equation in a Text Box
Entering a Cell Comment
Opening, Closing and Saving Documents
Opening or Creating Workbooks
The List of Recently Used Files
Using Close or Exit
Using Save or Save As
To Save a File for Use in Excel 2003
Editing a Worksheet
Inserting or Deleting Rows or Columns
Hiding Rows or Columns
Using Cut, Copy and Paste
Using Paste Special
Using Paste Special to Transpose Rows and Columns

Copying and Pasting a Picture of Cells
Using Clear
Copy, Cut or Paste Using Drag-and-Drop Editing
Duplicating Values or Formulas in a Range of Cells
Absolute, Relative and Mixed References
Relative References When Using Copy or Cut
Using AutoFill to Fill Down or Fill Right
Using AutoFill to Create a Series
The AutoFill Shortcut Menu
Formatting Worksheets
Using Column Width and Row Height
Formatting Cells
The Mini Toolbar
The Format Cells Dialog Box
Using Alignment
Using Font
The Alternate Character Set
Entering Subscripts and Superscripts
Using Border and Patterns
Using the Format Painter Toolbutton
Number Formatting
Using the Number Formatting Toolbuttons
Using Excel's Built-in Number Formats
Custom Number Formats

www.it-ebooks.info

22
22
23

24
24
25
26
26
27
27
27
27
28
28
28
30
30
31
33
33
34
34
35
36
37
37
37
39
40
40
42
42
43

44
46
46
47
47
48
48
48
49
51


ix

Contents
Custom Date Formats
Time Formats
Variable Number Formats
Conditional Number Formats
Formatting Numbers Using "Precision as Displayed"
Conditional Formatting (Part I)
Printing Documents
Using Page Setup
Using Print
Printing a Selected Range of Cells in a Worksheet
Using Set Print Area
Printing Row or Column Headings for a Multi-Page Worksheet
Protecting Data in Worksheets
Protecting a Workbook
Protecting a Workbook by Making It a Read-Only Workbook

Hiding a Worksheet
Protecting a Worksheet by Locking or Hiding Cell Contents
Controlling the Way Documents Are Displayed
Using New Window and Arrange
Different Views of the Same Worksheet
Using Split Screens
Using Freeze Panes
Using Zoom
Easing the Transition from Excel 2003 to Excel 2007/2010
Customize the Quick Access Toolbar
Use Shortcut Keys
Display Classic Menus
Excel 2007/2010 Workbook and Worksheet Specifications

53
53
54
54
54
55
59
61
62
63
64
64
64
65
65
65

67
69
69
71
71
72
73
73
74
74
74
77

Chapter 2 Working with Excel 2003
The Excel 2003 Document Window
Changing What Excel Displays
Moving or Resizing Documents
Navigating Around the Workbook
Changing the Name of a Worksheet
Changing the Color of Sheet Tabs
Rearranging the Order of Sheets in a Workbook
Selecting Multiple Worksheets: [Group] Mode
Navigating Around the Worksheet
Selecting a Range of Cells on the Worksheet
Selecting Non-Adjacent Ranges
Extending a Selection
Selecting a Block of Cells

79
80

82
82
83
83
83
84
85
85
86
86
86

www.it-ebooks.info


x

Excel for Chemists

Entering Data in a Worksheet
Entering Numbers
How Excel Stores and Displays Numbers
Entering Text
Entering Formulas
Editing Cell Entries
Adding a Text Box
;
Entering a Cell Comment
Using the Equation Editor
Excel's Menus: An Overview

Shortcut Menus
Menu Commands or Toolbuttons?
Opening, Closing and Saving Documents
Opening or Creating Workbooks
Using Move or Copy Sheet... or Delete Sheet
Using Close or Exit
Types of Excel Document
Using Save or Save As
Using Save Workspace
Editing a Worksheet
Inserting or Deleting Rows or Columns
Using Cut, Copy and Paste
Copying and Pasting Multiple Items
Using Paste Special
Using Paste Special to Transpose Rows and Columns
Using Clear
Using the Insert Menu
Copy, Cut or Paste Using Drag-and-Drop Editing
Duplicating Values or Formulas in a Range of Cells
Absolute, Relative and Mixed References
Relative References When Using Copy and Cut
Using AutoFill to Fill Down or Fill Right
Creating a Series
Using AutoFill to Create a Series
The AutoFill Shortcut Menu
Formatting Worksheets
Using Column Width... and Row Height
Formatting Cells
Using Alignment
Using Font

The Alternate Character Set
Entering Subscripts and Superscripts

www.it-ebooks.info

87
88
88
89
89
91
91
92
93
94
95
95
...95
95
96
96
97
97
97
98
98
99
99
100
101

101
101
102
103
104
105
105
105
106
107
108
108
108
109
Ill
111
112


Contents

xi

Using Border and Patterns
Using the Format Painter Toolbutton
Number Formatting
Using Excel's Built-in Number Formats
Custom Number Formats
Date Formats
Time Formats

:
Variable Number Formats
Conditional Number Formats
Using the Number Formatting Toolbuttons
Formatting Numbers Using "Precision as Displayed"
Using Conditional Formatting (Part I)
Printing Documents
Using Page Setup
Using Print Preview
Using Print
Printing a Selected Range of Cells in a Worksheet
Printing Row or Column Headings for a Multi-Page Worksheet
Protecting Data in Worksheets
Protecting a Workbook
Protecting a Workbook by Making it a Read-Only Workbook
Hiding a Worksheet
Protecting a Worksheet by Locking or Hiding Cell Contents
Controlling the Way Documents Are Displayed
Viewing Several Worksheets at the Same Time
Using New Window and Arrange
Different Views of the Same Worksheet
Using New Window
Using Split Screens
Using Freeze Panes
Opening Excel 2007/2010 Documents in Excel 2003
Excel 2003 Workbook and Worksheet Specifications

112
113
113

113
114
116
117
117
118
118
118
119
120
120
123
123
124
125
125
125
126
126
127
130
130
130
131
132
132
133
134
135


Chapter 3 Excel Formulas and Functions
The Elements of a Worksheet Formula
Constants
Operators
References: Absolute, Relative and Mixed
R1C1 Reference Style
Creating and Using External References
Creating an External Reference by Selecting
Creating an External Reference by Using Paste Link
The External Reference Contains the Complete Directory Path

137
137
137
138
139
140
140
140
141

www.it-ebooks.info


xii

Excel for Chemists

Updating References and Re-Establishing Links
141

Creating and Using 3-D References
142
Worksheet Functions: An Overview
143
143
Function Arguments
144
Nested Functions
144
New Functions Introduced in Excel 2007
Changes to Functions in Excel 2010
144
Using Insert Function
145
A Shortcut to a Function
147
Using Formula AutoComplete (Excel 2007/2010 Only)
147
Math and Trigonometric Functions
149
Trigonometric Functions
150
Functions for Working with Matrices
151
Statistical Functions
151
Logical Functions
152
The IF Function
153

Nested IF Functions
155
AND, OR and NOT
155
Using IFERROR (Excel 2007/2010 Only)
155
Using COUNTIF
156
Using SUMIF
156
157
Using AVERAGEIF (Excel 2007/2010 Only)
Using COUNTIFS, SUMIFS and AVERAGEIFS (Excel 2007/2010 Only).. 157
159
Using Conditional Formatting (Part II)
161
Date and Time Functions
161
How Excel Keeps Track of the Date and Time
Date and Time Arithmetic
162
Creating Date Series
162
Using Date and Time Functions
163
Examples of Date and Time Formulas
164
Text Functions
165
The LEN, LEFT, RIGHT and MID Functions

166
The UPPER, LOWER and PROPER Functions
166
The FIND, SEARCH, REPLACE, SUBSTITUTE and EXACT Functions 166
The FIXED and TEXT Functions
169
The VALUE Function
169
The CODE and CHAR Functions
169
Lookup and Reference Functions
170
Information Functions
171
Creating "Megaformulas"
172
Advantages and Disadvantages of Megaformulas
173
The Order in Which Excel Performs Operations in Formulas
174
Formula and Function Specifications
175

www.it-ebooks.info


Contents

xiii


Chapter 4 Excel 2007/2010 Charts
Chart Types
Creating a Chart
Chart Tools in the Ribbon
Activating, Resizing and Moving an Embedded Chart
The SERIES Function
Chart Elements
Selecting Chart Elements
Formatting Chart Elements
Creating Column or Bar Charts
Creating Line Charts
Creating Pie Charts
Creating Radar Charts
Creating Surface Charts (3-D Charts)
Creating XY Charts
Switching Between Chart Types
Formatting the Elements of an XY Chart
Formatting Chart Elements by Using the Mini Toolbar
Formatting a Data Series
Formatting Chart Elements with Color
Modifying an Axis Scale
Changing the Number Format of an Axis Scale
Changing the Dimensions of a Chart
When the X-Values of a Category Chart Are Dates
Tutorial on Creating Scientific Charts
Excel 2007/2010 Chart Specifications

177
177
179

181
181
182
182
183
183
186
188
192
194
195
196
197
197
198
199
200
201
202
203
206
207

Chapter 5 Excel 2003 Charts
Chart Types
Creating a Chart
Creating a Chart Using the ChartWizard
Chart Elements
The SERIES Function
Creating Column or Bar Charts

Creating Line Charts
Creating Pie Charts
Creating Radar Charts
Creating Surface Charts (3-D Charts)
Activating, Resizing and Moving an Embedded Chart
Formatting Charts: An Introduction
Using the Chart Menu
Using Chart Type... to Switch from One Chart Type to Another
Using Chart Options... to Add Titles, Gridlines or a Legend

209
209
209
213
213
214
215
215
218
220
221
221
222
222
222

www.it-ebooks.info


Excel for Chemists


XIV

Using Location... to Move or Copy an Embedded Chart
Formatting the Elements of an XY Chart
Selecting Chart Elements
Formatting Chart Elements
When the X-Values of a Category Chart Are Dates
Excel 2003 Chart Specifications
PART II

222
223
223
223
227
230

ADVANCED SPREADSHEET TOPICS

Chapter 6 Advanced Worksheet Formulas
Using Names Instead of References
Guidelines for Creating Names
Defining Names in Excel 2003
Using Define Name
Using Create Names
Using the Drop-Down Name List Box
Names Can Be Local or Global
Defining Names in Excel 2007/2010
Using Define Name

Using Create Names from Selection
Using the Name Manager
More about Using Names
A Reference Using Implicit Intersection
A Name Can Refer to a Constant or to a Formula
Entering a Name in a Formula by Selecting
Using Apply Names
Using Paste Name
Deleting Names
Changing a Name
Using Paste List or Paste Names
The Label... Command (Excel 2003 Only)
Worksheet Functions for the "Power User"
Information Functions
The CELL Function
The N Function
Lookup Functions
The CHOOSE Function
The VLOOKUP and HLOOKUP Functions
The INDEX and MATCH Functions
Getting Values from a One-Way Table
Getting Values from a Two-Way Table
Creating a Custom Lookup Formula to Obtain Values from a Table
Wildcard Characters with VLOOKUP, MATCH and Other Functions

www.it-ebooks.info

233
233
234

235
235
237
238
240
240
241
241
242
242
243
244
244
245
245
246
246
247
247
247
248
248
249
249
249
250
251
251
253
254



Contents

xv

The LOOKUP Function
Reference Functions
The OFFSET Function
The INDIRECT Function
The ADDRESS Function
Solving a Problem by Using Intentional Circular References
Using Excel 4 Macro Functions in Worksheet Formulas
Troubleshooting the Worksheet
Error Values and Their Meanings
Examining Formulas
Finding Dependent and Precedent Cells
Repairing or Removing Links in Documents
Re-establishing Links
Finding All Links in a Workbook

254
255
255
256
256
257
259
261
261

262
263
263
264
266

Chapter 7 Array Formulas
Introduction to Array Formulas
Array Constants
Formulas and Functions that Return an Array Result
Editing or Deleting Arrays
Creating a "Three-Dimensional" Array on a Single Worksheet
An Array Formula Example: Creating a Specialized SUMIF Formula
Evaluating Polynomials or Power Series Using Array Formulas
Using the ROW Function in Array Formulas
Using the INDIRECT Function in Array Formulas
Using Array Formulas to Work with Lists
Using Multiple Criteria to Count Entries in a List
Counting Common Entries in Two Lists
Counting Duplicate Entries in a List
Counting Unique Entries in a List
Indicating Duplicate Entries in a List
Returning an Array of Unique Entries in a List
Sorting by Using an Array Formula
Sorting a 1-D List of Numbers
Sorting a 2-D List Using a Column of Numbers as the Sortkey
"Auto-Alphabetizing" Using an Array Formula
Another Example: Validating a CAS Registry Number

267

269
270
270
271
272
273
274
274
274
275
276
278
278
279
280
281
282
282
285
286

Chapter 8 Advanced Charting Techniques
Charts with More than One Data Series
Plotting Two or More Different Sets of Y Values in the Same Chart
Plotting Two Different Sets of X and Y Values in the Same Chart
Alternate Data Layout for Two Different Sets of X and Y Values

289
289
291

292

www.it-ebooks.info


xvi

Excel for Chemists

Extending a Data Series or Adding a New Series
The Copy and Paste Method
The Drag-and-Drop Method
The Color-Coded Ranges Method
Using Source Data
Editing the SERIES Function in the Formula Bar
Customizing Charts
Good Charts vs. Bad Charts
Plotting Experimental Data Points and a Calculated Curve
Charts with Secondary Axes
An XY Chart with a Secondary Y Axis
A Chart with Secondary X Axis and Y Axis
A Column Chart with a Secondary Y Axis
Some Additional Customization Techniques
Adding Error Bars to an XY Chart
Using Sub- or Superscripts in Chart Legends
Modifying Tick Mark Labels on Axis Scales
Adding Data Labels to an XY Chart
Logarithmic Charts
Linking Chart Text Elements to a Worksheet
To Switch Plotting Order in an XY Chart

Getting Creative with Charts
A Chart with an Additional Axis
A Chart that Updates Automatically
Changing the Default Chart Format
Saving a Chart Template in Excel 2007/2010
Changing the Default Chart Format in Excel 2003
Copying and Pasting Chart Formatting
Excel Chart Specifications

293
293
293
294
295
297
297
298
298
301
301
304
306
308
308
313
313
315
315
316
316

317
317
320
321
321
322
324
326

Chapter 9 Using Excel's Database Features
The Structure of a List or Database
Creating a Database
Defining a Database
Adding or Deleting Records or Fields
Updating a Database Using Data Form
Sorting a List
Sorting a List Using Excel 2003
Sorting According to More Than One Field
Sorting a List Using Excel 2007/2010
Sort Options
Using AutoFilter to Obtain a Subset of a List
Using Multiple Data Filters

327
327
328
328
329
330
331

332
332
333
335
339

www.it-ebooks.info


Contents

xvii

Using Advanced Filter to Obtain a Subset of a List
Defining and Using Selection Criteria
Using Multiple Criteria
Special Criteria for Text Entries
Extracting Records
Using Database Functions

340
341
342
344
344
346

Chapter 10 Importing Data into Excel
Direct Input of Instrument Data into Excel
Importing Data Files Using the Text Import Wizard

Importing a Delimited File
Importing a Fixed-Width File
Using Convert Text to Columns
Parsing a Delimited File
Parsing a Fixed-Width File
From Hard Copy (Paper) to Excel
Using a Scanner to Transfer Numeric Data to Excel
Using a Scanner to Transfer Graphical Data to Excel
Selecting Every Mh Data Point
Using AutoFill
Using the Sampling Tool
Using a Worksheet Formula

349
350
350
353
353
354
355
358
358
360
361
361
362
363

Chapter 11 Adding Controls to a Spreadsheet
Option Buttons, Check Boxes, List Boxes and Other Controls

How to Add a Control to a Worksheet
Control Properties
A List Box on a Worksheet
A Drop-down List Box on a Worksheet
Option Buttons with a Drop-down List Box
Using a Check Box to Enable or Disable Conditional Formatting
How to Add a Hyperlink to a Worksheet
Inserting a Hyperlink
Using Paste as Hyperlink
Using the HYPERLINK Worksheet Function
Using Data Validation
Specifying Input Values
Specifying an Input Message or Error Alert
Using the Custom Category

365
366
367
369
370
371
373
373
373
376
376
378
379
381
382


Chapter 12 Other Language Versions of Excel
Differences in the Display of Numbers
Decimal and Thousands Separators
Argument Separators in Functions

385
385
386

www.it-ebooks.info


xviii

Excel for Chemists

Array Separators
Differences in the Display of Dates
Date Formats
Date Formatting Symbols
Creating Custom Date Formats for Other Language Versions
Importing Data
Importing Values that Are Numbers
Importing Values that Are Dates Using the Text Import Wizard
Worksheet Function Names in Other Languages
The FunctionName Translator
PART III

387

387
387
388
389
390
390
391
393
399

SPREADSHEET MATHEMATICS

Chapter 13 Mathematical Methods for Spreadsheet Calculations
Interpolation
Table Lookup with Linear Interpolation
Cubic Interpolation
Arrays, Matrices and Determinants
An Introduction to Matrix Mathematics
Numerical Differentiation
First and Second Derivatives of a Data Set
Derivatives of a Function
Numerical Integration
Finding the Area Under a Curve
Finding Roots of Equations
The Graphical Method
The Method of Successive Approximations
The Secant Method
Using Goal Seek
Solving Sets of Simultaneous Linear Equations
Cramer's Rule

Solution Using Matrix Inversion
Analysis of Spectra of Mixtures Using Matrix Mathematics
Applying Cramer's Rule to a Spectrophotometric Problem
Analysis of Spectra of Mixtures Using Matrix Inversion
Polar to Cartesian Coordinates
Significant Figures

403
403
405
407
408
410
411
414
415
416
418
419
419
421
423
425
426
427
428
428
430
430
432


Chapter 14 Linear Regression and Curve Fitting
Linear Regression
Least-Squares Fit to a Straight Line
Using the SLOPE, INTERCEPT and RSQ Functions
Multiple Linear Regression
Using LINEST to Perform Multiple Linear Regression

435
436
437
438
439

www.it-ebooks.info


Contents

xix

Least-Squares Fit to a Straight Line Using the LINEST Function
Regression Line Without an Intercept
The Regression Parameters
Multiple Linear Regression: An Example
Fitting Data Using a Power Series
A LINEST Shortcut for Power Series
Handling Noncontiguous Ranges of known_x's in LINEST
How LINEST Handles Collinearity
Weighted Least Squares

Multiple Linear Regression Using Trendline
Multiple Linear Regression Using the Analysis ToolPak
Using the Regression Tool
Using the Regression Statistics
Testing Whether an Intercept Is Significantly Different from Zero
Testing Whether Two Slopes Are Significantly Different
Testing Whether a Regression Coefficient Is Significant
Testing Whether Regression Coefficients Are Correlated
Confidence Intervals for Slope and Intercept
Confidence Limits and Prediction Limits for a Straight Line
Chapter 15 Nonlinear Regression Using the Solver
Nonlinear Regression
Using the Solver to Perform Nonlinear Least-Squares Curve Fitting
Using the Solver for Optimization
Changes to the Solver in Excel 2010
Using the Solver for Least-Squares Curve Fitting
Using the Solver: An Example
Comparison with a Commercial Nonlinear Least-Squares Package
Solver Options (Excel 2007 or 2003)
Solver Options (Excel 2010)
The "Use Automatic Scaling" Option Is Important for Many Chemical
Problems
Some Additional Solver Examples
Deconvolution of Spectra
Determination of Binding Constants by NMR Measurements
Other Examples: NIST Datasets
Statistics of Nonlinear Regression
A Macro to Provide Regression Statistics for the Solver
Using the Solver Statistics Macro
An Additional Benefit from Using the Solver Statistics Macro


www.it-ebooks.info

440
441
441
442
445
447
448
450
451
451
453
455
457
457
459
460
460
461
461
463
464
464
465
465
466
472
472

474
476
476
476
480
484
484
485
485
487


xx
PART IV

Excel for Chemists
EXCEL'S VISUAL BASIC FOR APPLICATIONS

Chapter 16 Visual Basic for Applications: An Introduction
The Visual Basic Editor
Visual Basic Procedures and Modules
There are Two Kinds of Procedure:
Sub Procedures and Function Procedures
The Structure of a Sub Procedure
The Structure of a Function Procedure
Using the Recorder to Create a Simple Sub Procedure
Recording a Simple Macro Using Excel 2007/2010
Recording a Simple Macro Using Excel 2003
The Personal Macro Workbook
Running a Sub Procedure

Assigning a Shortcut Key to a Sub Procedure
Creating a Simple Custom Function
Using a Function Macro
How Do I Save a Macro?

494
495
495
496
496
498
499
500
501
501
501
502

Chapter 17 Programming with VBA
Creating Visual Basic Code
Entering VBA Code
Components of Visual Basic Statements
Operators
Variables and Arguments
Objects, Properties and Methods
Objects
Some Useful Objects
"Objects" that Are Really Properties
You Can Define Your Own Objects
Making a Reference to a Cell or Range of Cells

Making a Reference to a Selected Cell or Range
Making a Reference to a Cell Other than the Active Cell
References Using the Union or Intersect Method
Getting Values from a Worksheet
Sending Values to a Worksheet
Properties
Properties of the Range Object
Some Useful Properties
Methods
Some Useful Methods
Two Ways to Specify Arguments of Methods
Arguments with or without Parentheses

503
503
504
504
504
505
505
506
506
507
507
507
508
510
510
510
510

511
511
512
512
512
513

www.it-ebooks.info

491
494


Contents

xxi

VBA Functions
Using Worksheet Functions with VBA
VBA Commands
VBA Data Types
The Variant Data Type
Declaring Variables or Arguments in Advance
Specifying the Data Type of an Argument
Specifying the Data Type Returned by a Function Procedure
String Data Types
The Boolean (Logical) Data Type
Type Declaration Characters
Program Control
Decision-Making (Branching)

Logical Operators
Looping
For...Next Loops
For Each...Next Loops
Do While...Loop
Exiting from a Loop or from a Procedure
Subroutines
Scoping a Subroutine
Interactive Macros

513
514
515
515
516
516
516
516
517
517
518
518
518
520
521
521
521
522
522
522

523
524

MsgBox

524

MsgBox Return Values

525

InputBox

526

Using a Dialog Box to Open a Workbook
Using the GetOpenFilename Method
Using Excel's Built-in Dialog Boxes
Other Ways to Display Built-in Dialog Boxes
Using Excel 4 Macro Commands
Testing and Debugging
Tracing Execution
Stepping Through Code
Adding a Breakpoint
Examining the Values of Variables Using the Mouse Pointer
Examining the Values of Variables Using the Watch Pane
Using Conditional Watch
Using VBA On-Line Help
Using VBA Help (Excel 2007/2010)
Using VBA Help (Excel 2003)

Using the Object Browser
Some Ways to Improve Performance (i.e., Speed)

www.it-ebooks.info

527
528
529
530
531
532
533
534
534
535
536
537
538
538
539
539
541


Excel for Chemists

XXH

Chapter 18 Working with Arrays in VBA
Visual Basic Arrays

Dimensioning an Array
Use the Name of the Array Variable to Specify the Whole Array
Dynamic Arrays
Preserving Values in Dynamic Arrays
Using Arrays in Sub Procedures:
Passing Values from Worksheet to VBA Module
Using a Loop to Transfer Values from a Worksheet to a VBA Array
A Range Specified in a Sub Procedure Becomes an Array Variable
Some Worksheet Functions Used Within VBA Create an Array
Using Arrays in Sub Procedures:
Passing Values from VBA Module to Worksheet
Using a Loop to Transfer Values from a VBA Array to a Worksheet
Equating a VBA Variable to a Worksheet Range
A One-Dimensional Array Assigned to a Worksheet Range
Can Cause Problems
Using Arrays In Function Procedures
From Worksheet to Module
A Range Passed to a Function Procedure
Automatically Becomes an Array
Passing an Indefinite Number of Arguments
Using the ParamArray Keyword
Using Arrays in Function Procedures:
Returning an Array of Values as a Result
PART V

543
543
544
544
545

545
545
546
547
547
547
548
548
550
550
551
552

SOME APPLICATIONS OF VBA

Chapter 19 Command Macros
Creating Advanced Macros in VBA
A Sub Procedure to Format Text as a Chemical Formula
Adding Enhancements to the Chemical Format Macro
Adding More Enhancements
A Sub Procedure to Apply "Precision as Displayed"
to a Selected Range of Cells
A Sub Procedure to Apply Data Labels in a Chart
Quick Chart: Create Excel 2007/2010 Charts with One Click
Chapter 20 Custom Functions
Some Additional Tools for Creating Custom Functions
Arrays as Arguments or as Return Values
Returning an Array Result in Either a Row or a Column
Returning an Error Value
A Custom Function that Takes an Optional Argument


www.it-ebooks.info

557
557
558
560
562
563
568
571
571
571
572
573


Contents

xxin

A Custom Function that Takes an Indefinite Number of Arguments
573
Providing a Description for a Function
in the Paste Function Dialog Box
576
Providing Descriptions for Function Arguments
in the Paste Function Dialog Box (Excel 2010 Only)
576
Assigning a Custom Function to a Function Category

577
A Custom Function to Calculate Acid-Base Species Distribution Diagrams ...578
A Custom Statistical Function
580
A Custom Function to Calculate Molecular Weights
583
Creating Add-In Function Macros
585
How to Create an Add-In Macro
585
How to Load/Unload an Add-In Macro
586
How to Delete an Add-In Macro
586
How to Protect an Add-In Workbook
587
How to Edit an Add-In Workbook
or Convert a .xla File to a .xls File
587
Advantages and Disadvantages of Using Function Macros
587
Chapter 21 Automatic Procedures
OnEvent Procedures
AutoOpen or AutoClose Procedures
OnEvent Procedures
Some Examples of OnEvent Code
Using OnUndo
Event-Handler Procedures
Creating a Workbook_Open Procedure


589
589
590
591
592
592
594

Chapter 22 Custom Menus
Modifying Menu Bars, Menus or Menu Commands in Excel 2003
Adding or Removing a Menu Command
Creating a New Menu Bar
Adding a Custom Menu to a Menu Bar
Adding a Custom Menu Command to a Menu
Modifying Menus or Menu Bars by Using VBA
The Basic Structure of a Procedure to Install a New Menu Command
Adding a Menu Command by Means of an Event-Handler Procedure
Exiting Gracefully: Removing a Menu Command
Modifying a Built-in Menu Command
Installing Menu Bars, Menus or Menu Commands in Excel 2007/2010
Displaying Classic Menus in Excel 2007/2010

595
595
596
597
598
598
599
601

602
602
603
603

www.it-ebooks.info


Excel for Chemists

XX1V

Chapter 23 Custom Toolbars and Toolbuttons
Customizing Toolbars in Excel 2003
Moving and Changing the Shape of Toolbars
Activating Other Toolbars
Adding or Removing Toolbuttons from Toolbars
Creating a New Toolbar
Creating Custom Toolbuttons
The ToggleNumberFormat Macro
The FullPage Macro
Creating a Custom Toolbutton Image
How to Add a ToolTip to a Custom Button
Customizing in Excel 2007
Moving the Quick Access Toolbar
Adding a Built-in Command Button to the Quick Access Toolbar
Adding a Custom Toolbutton to the Quick Access Toolbar
Adding Custom Toolbuttons to the Ribbon
How to Use the Excel 2003 Button Editor in Excel 2007/2010
Removing Custom Toolbuttons from the Ribbon

Customizing the Ribbon (Excel 2010 Only)

607
607
608
609
610
611
613
614
615
617
618
618
618
620
621
622
622
623

PART VI
Appendix A
Appendix B
Appendix C
Appendix D
Appendix E
Appendix F
Appendix G
Appendix H

Appendix I
Appendix J
Appendix K

629
63 3
639
661
663
667
689
693
703
707
709

APPENDICES
What's Where in Excel 2007/2010
Selected Worksheet Functions by Category
Alphabetical List of Selected Worksheet Functions
Renamed Functions in Excel 2010
Selected Visual Basic Keywords by Category
Alphabetical List of Selected Visual Basic Keywords
Selected Excel 4 Macro Functions
Shortcut Keys by Keystroke
Selected Shortcut Keys by Category
ASCII Codes
Contents of the CD-ROM

INDEX


719

www.it-ebooks.info


Preface to the Third Edition
Since the publication of the second edition of Excel for Chemists in 2001,
three new versions of Excel for the PC have appeared: Excel 2003, Excel 2007
and Excel 2010. With Excel 2007, Microsoft introduced a radically new user
interface: the Ribbon, which replaced the familiar menus of earlier versions.
The change was so extreme that many users have opted to stay with the "triedand-true" version, Excel 2003, as long as possible. For this reason, this edition
covers Excel 2003 as well as the newer Excel 2007/2010.
There are several new chapters in this edition. Two chapters discuss the
features of the new Excel 2007/2010 (plus a new appendix, "What's Where in
Excel 2007/2010"), a chapter covers automatic procedures—macros that run
automatically—in more detail than was covered in the previous edition, and
there is a completely new chapter that discusses how to handle documents
created in other language versions of Excel.
Much of the material in this book has been incorporated in courses entitled
"Excel for Scientists and Engineers" and "Excel Visual Basic Macros for
Scientists and Engineers" which have been presented to over 2500 scientists in
the United States, Canada and Europe—not only chemists, but also scientists in
many other disciplines. Many changes in this edition were made in light of the
experience gained in teaching these courses.

Acknowledgments
Dr. Faith A Morrison, Department of Chemical Engineering, Michigan
Technological University, for her "Guidelines on Graphing" used in Chapter 4.
Dr. Lev Zompa, University of Massachusetts-Boston, for spectrophotometric data used in Chapter 19.

Dr. Steve Bell, for NMR data used in Chapter 20.

E. Joseph Billo
May 2011

XXV

www.it-ebooks.info


Preface to the Third Edition
Since the publication of the second edition of Excel for Chemists in 2001,
three new versions of Excel for the PC have appeared: Excel 2003, Excel 2007
and Excel 2010. With Excel 2007, Microsoft introduced a radically new user
interface: the Ribbon, which replaced the familiar menus of earlier versions.
The change was so extreme that many users have opted to stay with the "triedand-true" version, Excel 2003, as long as possible. For this reason, this edition
covers Excel 2003 as well as the newer Excel 2007/2010.
There are several new chapters in this edition. Two chapters discuss the
features of the new Excel 2007/2010 (plus a new appendix, "What's Where in
Excel 2007/2010"), a chapter covers automatic procedures—macros that run
automatically—in more detail than was covered in the previous edition, and
there is a completely new chapter that discusses how to handle documents
created in other language versions of Excel.
Much of the material in this book has been incorporated in courses entitled
"Excel for Scientists and Engineers" and "Excel Visual Basic Macros for
Scientists and Engineers" which have been presented to over 2500 scientists in
the United States, Canada and Europe—not only chemists, but also scientists in
many other disciplines. Many changes in this edition were made in light of the
experience gained in teaching these courses.


Acknowledgments
Dr. Faith A Morrison, Department of Chemical Engineering, Michigan
Technological University, for her "Guidelines on Graphing" used in Chapter 4.
Dr. Lev Zompa, University of Massachusetts-Boston, for spectrophotometric data used in Chapter 19.
Dr. Steve Bell, for NMR data used in Chapter 20.

E. Joseph Billo
May 2011

XXV

www.it-ebooks.info


Before You Begin
Which Version of Excel Are You Using?
This book is for users of Excel 2003 for Windows or Excel 2007/2010 for
Windows.
The second edition of this book covered both Excel for the PC and Excel for
the Macintosh, but since Excel 2008, the Macintosh version corresponding to
Excel 2007, doesn't support Visual Basic for Applications (VBA), I decided not
to include Mac-specific instructions in this third edition.

Typographic Conventions
As you read through this book, you'll see several different fonts and
capitalization styles within the text. Here are the conventions that I've used.
• Excel 2003 menu headings and menu commands are in boldface type, e.g.:
File, Format, Delete....
• Excel 2007/2010 Ribbon tab names, icon names and menu command names
are in non-bold, e.g.,

"the Insert icon in the Cells group in the Home tab", "click on Paste
Special..."
• For clarity, the titles of some dialog boxes and options are enclosed in
quotes, e.g.:
"When Creating New Workbooks"
• Cell references are in Arial font, e.g.:
"In cell A9 ..."
• Worksheet functions are in Arial font, e.g.:
SUM, LINEST
• Excel's built-in argument names (i.e., placeholder arguments) in functions
are in Arial italic; required arguments are in bold italic, e.g.:
LINEST(frnown_y's, known_x's, const, stats)

xxvu

www.it-ebooks.info


×