F 1 Activex
F 1 Activex
TM TM TM TM
TM
For Microsoft Visual Basic 5.0 and 6.0 , Visual C++ 5.0 and 6.0 , and Other Languages Version 6.1
Information in this document is subject to change without notice. Companies, names, and data used in examples herein are fictitious unless otherwise noted. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Tidestone Technologies, Inc. Copyright 1999 Tidestone Technologies, Inc. All rights reserved. Formula One is a licensed trademark and Visual Components, First Impression, and VisualSpeller are registered trademarks of Tidestone Technologies, Inc. Microsoft, MS, MS-DOS, Visual Basic, and Windows are registered trademarks and Microsoft Access and Microsoft Excel are trademarks of Microsoft Corporation in the USA and other countries. Java, 100% Pure Java, and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc., in the U.S. and other countries. PowerBuilder is a trademark of Sybase, Inc. or its subsidiaries. TrueType is a registered trademark of Apple Computer, Inc. All other company and product names mentioned may be trademarks or registered trademarks of the companies with which they are associated. The Tidestone License Agreement, included with the product, specifies the permitted and prohibited uses of the product. Any unauthorized reproduction or use of the product, or breach of the terms and conditions of the License Agreement, is forbidden. The Tidestone License Agreement sets forth the only warranties applicable to the product and documentation. All warranty disclaimers and exclusions set forth therein apply to the information contained in this document. Published by: Tidestone Technologies, Inc. 12980 Metcalf Avenue, Suite 300 Overland Park, Kansas 66213 (913)851-2200 (800)884-8665 (913)851-1390 fax www.tidestone.com
iii
Contents
Preface Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix New Features in Formula One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Version 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Version 6.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Installing the Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi What Does The Installation Program Do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi After Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii If you Experience Installation Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Documentation Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii Chapter 1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Adding the ActiveX Control to Your Application . . . . . . . . . . . . . . . . . . . . . . . . 1 Getting Started in Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Creating a Dialog, CFormView, or CView-Based Application . . . . . . . . . . . . . 2 Creating Dialog Box-Based Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Creating CFormView-Based Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Creating CView-Based Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Adding the Formula One Component to Your Project . . . . . . . . . . . . . . . . . . . . 3 Adding the Component to Your Dialog or CFormView . . . . . . . . . . . . . . . . . . 4 Adding the Formula One Component to Your CView . . . . . . . . . . . . . . . . . . . . 5 Working With Top-Level Properties and Methods in Visual C++ . . . . . . . . . . . 6 Accessing Formula One Objects in Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . 6 Handling Events in your Dialog or CFormView in Visual C++ . . . . . . . . . . . . 7 Handling Events in your CView in Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . 7 Handling Printing and Previewing in Visual C++ . . . . . . . . . . . . . . . . . . . . . . . 7 Serializing the Control in Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Setting Properties in Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Setting Properties for a Control on a CView . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Getting Started in Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Adding the Component to your Visual Basic 5.0 or 6.0 Project . . . . . . . . . . . . . 8 Setting Properties in Visual Basic 5.0 or 6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Getting Started in PowerBuilder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 OLE 2 Presentation Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Uniform Data Transfer Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Standalone Worksheet Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Using Formula One as a Worksheet in PowerBuilder . . . . . . . . . . . . . . . . . . . 18
iv
Chapter 2 Introducing Formula One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Working with API Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Understanding Workbooks and Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Introducing the Workbook Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Using Workbooks, Views, and Invisible Workbooks . . . . . . . . . . . . . . . . . . . . 25 Working With the F1Book Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Working With the F1BookView Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Using Attach Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Controlling the Display of Workbook Areas . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Saving View or Invisible Workbook Information . . . . . . . . . . . . . . . . . . . . . . 32 Reading and Writing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Using BLOB access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Writing out a Range of Cell Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Chapter 3 Overview of the Workbook Designer . . . . . . . . . . . . . . . . . . . . . . . Launching the Workbook Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Docking the Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Workbook Designer Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Workbook Designer Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 36 37 37 42
Chapter 4 Workbook Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Setting up Workbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Displaying Parts of the Workbook Designer . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Setting the Default Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Setting Up the Color Palette . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Manipulating Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Inserting Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Selecting Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Working with a Group of Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Inserting Multiple Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Deleting Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Renaming Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Setting Display Options for Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Navigating Through Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Navigating with the Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Navigating with the Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Selecting Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Selecting Cells with the Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Selecting Cells with Properties and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Selecting Rows and Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Setting Selection Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Contents
Chapter 5 Working With Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Understanding Worksheet Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Adding the Formula Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Entering Data with Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Entering Multi-Line Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Understanding Worksheet Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Entering Constant Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Entering Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Using Formula Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Understanding Cell References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Understanding Worksheet Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Displaying Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Built-In Worksheet Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Understanding Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Entering Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Using Autofill Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Adding Autofill Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Deleting Autofill Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Using Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Calculating Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Setting Automatic Recalculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Setting Minimal Recalculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Solving Circular References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Limiting Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Denying Access to a Workbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Denying Access to a Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Denying Access to Certain Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Denying Access to Row and Column Headings . . . . . . . . . . . . . . . . . . . . . . . . 82 Restricting Cell Data to Certain Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Denying Entry of Formulas in a Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Restricting the Use of Certain Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Restricting the Use of Certain Mouse Actions . . . . . . . . . . . . . . . . . . . . . . . . . 86 Chapter 6 Editing Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Copying, Moving, and Pasting Selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Using Dragging to Move, Copy, and Paste Selections . . . . . . . . . . . . . . . . . . . 87 Using Menu Commands to Move, Copy, and Paste Selections . . . . . . . . . . . . 91 Using Methods to Edit, Move, Copy, and Paste Selections . . . . . . . . . . . . . . . 92 Transferring Data via Uniform Data Transfer . . . . . . . . . . . . . . . . . . . . . . . . . 93 Finding and Replacing Data in Formula One . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Inserting Cells, Rows, and Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Clearing and Deleting Cells, Rows, and Columns . . . . . . . . . . . . . . . . . . . . . . 97 Sorting Data in Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
vi
Chapter 7 Formatting Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Using Built-in Number Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Applying Number Formats to Rows and Columns . . . . . . . . . . . . . . . . . . . . . 101 Obtaining Formatted Text Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . 101 Creating Custom Number Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Formatting Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Aligning Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Merging Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Cutting, Copying, and Pasting Merged Cells . . . . . . . . . . . . . . . . . . . . . . . . . 109 Changing Row Height and Column Width . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Setting Default Row Height and Width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Sizing Rows and Columns Using Menu Commands . . . . . . . . . . . . . . . . . . . 111 Sizing Rows and Columns Using Click and Drag Actions . . . . . . . . . . . . . . . 112 Sizing Rows and Columns with Properties and Methods . . . . . . . . . . . . . . . . 113 Freezing Horizontal and Vertical Panes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Setting Cell Border and Fill Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Setting Cell Borders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Setting Cell Fill Colors and Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Formatting Row and Column Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Selecting Row and Column Heading Areas . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Sizing Row and Column Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Setting Row and Column Heading Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Chapter 8 Working With Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . 123 Creating Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Creating Graphical Objects with Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Interactively Drawing Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Picture Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Setting Mouse Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Identifying Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Naming Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Selecting Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Interactively Selecting Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Selecting Graphical Objects Programmatically . . . . . . . . . . . . . . . . . . . . . . . 129 Moving, Sizing, and Arranging Graphical Objects . . . . . . . . . . . . . . . . . . . . . 130 Interactively Moving and Sizing Graphical Objects . . . . . . . . . . . . . . . . . . . . 130 Positioning Graphical Objects Programmatically . . . . . . . . . . . . . . . . . . . . . . 131 Determining Graphical Object Position and Size . . . . . . . . . . . . . . . . . . . . . . 132 Arranging Overlapping Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Formatting Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Formatting Colors and Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Formatting Lines (Borders) on Graphical Objects . . . . . . . . . . . . . . . . . . . . . 134 Showing and Hiding Graphical Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Contents
vii
Formatting Dropdown List Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Formatting Check Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 Formatting Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Selecting Check Box and Dropdown List Box Items . . . . . . . . . . . . . . . . . . . 137 Setting Values Interactively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Setting Values Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Setting Values by Cell Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Editing Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Chapter 9 Working With Chart Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Creating Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Using the Chart Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Navigating in the Chart Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Using the Gallery Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Using the Style Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Using the Layout Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Using the Axes Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Chart Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 Referencing Data on Another Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Chapter 10 Printing Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing Worksheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Print Areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Print Titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Page Breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Margins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Page Numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Headers and Footers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Page Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Up Scaling for Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Page Printing Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Choosing Paper Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying Miscellaneous Printing Options . . . . . . . . . . . . . . . . . . . . . . . . . . Previewing Your Printout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 149 150 151 152 154 155 156 157 157 158 158 158 159
Chapter 11 Working With Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Overview of Formula One Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Installing the ODBC Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Setting up a Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Connecting to the Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Querying the Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Updating or Inserting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Using PREPARE Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Binding Worksheet Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
viii
Executing PREPARE Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 Disconnecting from the Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Chapter 12 Using Formula One With the Internet . . . . . . . . . . . . . . . . . . . . 171 Writing out a Worksheet File in HTML Format . . . . . . . . . . . . . . . . . . . . . . . 171 Embedding Formula One Data in an HTML file . . . . . . . . . . . . . . . . . . . . . . 172 Introducing Internet Application Development . . . . . . . . . . . . . . . . . . . . . . . . 173 Viewing a Web Page Containing Formula One . . . . . . . . . . . . . . . . . . . . . . . 173 Adding Formula One to your Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Using Methods and Events for Internet Development . . . . . . . . . . . . . . . . . . 174 Understanding Formula Ones IObjectSafety Support . . . . . . . . . . . . . . . . . . 174 Understanding Formula Ones Safe Events . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Chapter 13 Performance Tuning and Specifications . . . . . . . . . . . . . . . . . . Using Performance Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Optimizing Formula One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Understanding Formula Ones Data Structure . . . . . . . . . . . . . . . . . . . . . . . . Allocating and Freeing Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Filling Worksheets with Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Technical Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 177 178 178 179 179 180
Chapter 14 Creating Add-In Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Formula One ActiveX Add-Ins in Visual Basic . . . . . . . . . . . . . . . . . . . . . . . 183 General Design Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Thread Safety . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Add-In Function Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Visual Basic Example Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Formula One C++ Add-In API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 How Add-In Functions Are Declared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 How Add-In Functions Are Exposed to Formula One . . . . . . . . . . . . . . . . . . 190 How Arguments and Return Values Are Passed . . . . . . . . . . . . . . . . . . . . . . 191 IF1AddInArrayEx interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Formula Evaluation Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 C++ Example Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Chapter 15 A-Z Worksheet Function Reference . . . . . . . . . . . . . . . . . . . . . . 203 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Preface
ix
P R E F A C E
Overview
Formula One is a high-performance workbook control that allows you to create, manipulate, and print worksheets. It contains the tools needed to store, analyze, manipulate, and present your data.
Excel 97 support. Formula One supports the Excel 97 and 95 file formats. Formula One reads and writes worksheets compatible with Excel 97 and 95. Minimal recalculation. Formula One now supports minimal recalculations. Under some circumstances, this can cause a dramatic improvement in recalculation speed. For information on minimal recalculation, see Setting Minimal Recalculation on page 78. Worksheet size has quadrupled. Formula One now supports worksheets up to 65,536 rows long. This is four times the number of rows that the previous version of Formula One provided. Cell capacity has increased. Each cell in a worksheet can contain as much as 16KB of text. Cells can now be merged. Formula One lets you merge two or more adjacent cells. This opens up a wide range of worksheet formatting possibilities. For example, developers and users can use merged cells to quickly and easily create multicolumn headings and titles, to insert blocks of text in worksheets, or to specify backgrounds and borders. For more information on cell merging, see Merging Cells on page 109. New find and replace method. The Formula One API has a new and improved way of doing find and replace through the API. It uses a a new API object, F1FindReplaceInfo. A search can be set up by using the new DefineSearch method to create a FindReplaceInfo object. The search itself is done using the
new FindNext method. The new Replace method replaces the found data with new data. For information about these new objects and methods, see the Formula One Online Documentation.
s
New format for fractions. Formula One now allows users to specify the denominator for fractional data. Now you can express a value of 0.8 as 4/5 or as 8/10 or even as 80/100. Enhanced printing features. Several printing improvements have been added to this version. Included is the new F1PageSetup Object that gives developers a wide range of paper size choices, increased control over worksheet page numbering, and the ability to set the number of copies Formula One prints by default. The Page Setup dialog box has also been redesigned. For more information on the new Page Setup features, see Printing Worksheets on page 149. Increased date range. Dates through the year 9999 are now accepted. The limit in previous versions of Formula One was 2078. Improved cell editing. When editing a cell, the in-cell edit space expands as needed to accommodate input. New worksheet function. Formula One now supports the SUMPRODUCT worksheet function. See page 263. Mouse handling. Support now exists for the IntelliPoint mouse. Hiding the scroll bars will prevent the user from using the mouse wheel to scroll.
Version 6.1
s
Add-In Functions. Formula One Version 6.1 provides Add-In function support using Visual Basic and C++. This allows developers to add their own functions to Formula One. See Creating Add-In Functions on page 183 for details.
Installation
The Installer Program can be used to install both trial and working versions of Formula One. You are prompted for a valid serial number during installation. If you enter a valid serial number, Formula One successfully installs as a working developer version. The product is installed as a trial (demo) version if you do one of the following:
s
press ENTER at the serial number prompt unsuccessfully attempt to enter a serial number three times
Preface
xi
The trial version of a product is a NON-REDISTRIBUTABLE component and will expire after 30 days. You cannot deploy applications with this version. The trial version displays the About box every 30 minutes reminding you that you are working with an evaluation version of the product. If you wish to continue evaluating the product after the 30-day trial, contact Tidestone at (913) 851-2200 or [email protected].
Allows you to identify the components you want to install, select a directory to hold the program files, and specify a folder in which to place the program on your desktop. Copies the files to your hard disk. Updates system files in your Windows system directory or the location of your choice. Records your serial number. During the installation process, you enter the product serial number provided on the installation media and product registration card. The serial number is recorded and displayed in your products About Box. You are required to provide your serial number to receive technical support and upgrade pricing on future product releases. Registers the ActiveX control with the Windows Registration Database. This makes the control visible and available to your development environment.
xii
After Installation
Once you install the product, you can determine if you have a full version of the product or a trial version by displaying the About box. To display the About box, use the AboutBox method or choose Help > About VCF1 in the standalone Workbook Designer. Text in the About Box tells you whether you are using an evaluation copy. After you successfully install a full version on your system, you can distribute that ActiveX control to your end users without worrying that the About box might display on their system every 30 minutes.
Technical Support
The Tidestone technical support staff can help you with any problem you encounter installing or using Formula One. If you need assistance, contact Tidestone in any of the following ways:
s
On the World Wide Web. For best service, send your technical support requests directly to the Tidestone Case Tracking System, which you can access from the Tidestone web site. Point your browser at: http://www.tidestone.com/support/tsmain.htm
By telephone. You can contact our technical support staff at (913) 851-2200 on weekdays between 9:00 a.m. and 4:00 p.m., central time. By fax. You can contact us by FAX at (913) 851-1390. By mail. Address your correspondence to: Tidestone Technical Support Department 12980 Metcalf, Suite 300 Overland Park, KS 66213
Preface
s
xiii
In Europe, contact: Tidestone Europe Lenexa House 11 Eldon Way Paddock Wood, Kent England TN12 6BE Tel: +44 1892 834343 Fax: +44 1892 835843
Documentation Conventions
Throughout this documentation, typographic conventions are used to define elements and references to Formula One items. .
Convention example AxisSelected, AllowSelections, Select, Description Names of events, properties, and methods, are in proper case and bold font. A series of numbered instructions are preceded by an introductory line. The introductory line begins with an arrowhead. Numbered instructions provide step-by-step directions for performing tasks. The instructions should be performed in the order they are presented. In numbered steps, items you are to enter are shown in Letter Gothic font. In general sections, italic text is used for the first occurrence of a new term. In reference sections, italic text indicates variable or argument information you must supply. In reference sections, italic text surrounded by square brackets indicates optional arguments. In reference sections, text surrounded by braces indicates you must make a choice among the items inside the braces. Choices are separated by vertical bars. Letter Gothic font is used for all code examples. File names are presented in upper case text. comment. Format > Sheet > Properties Choose the Properties option on the Sheet submenu of the Format menu.
1.Type a:\setup.
workbook fontname
[axis_id] {TRUE|FALSE}
F1Book2.ATTACH F1Book1.Title
TTF16.OCX
Tidestone
C H A P T E R
Getting Started
The Formula One control can be used as an ActiveX control with several Windows-based development environments, including Microsoft Visual Basic, Microsoft Visual C++, and PowerBuilder. This chapter describes how to get started using Formula One with these development environments.
add the control to your project select the controls tool from the toolbar and draw the control on a form or in a window
For steps about adding the Formula One control to your application, refer to the following sections:
s
Getting Started in Visual C++ on page 1 Getting Started in Visual Basic on page 8 Getting Started in PowerBuilder on page 9
Important Visual C++ does not read constants such as F1Auto from the ActiveX control, so the file TTF16.h, distributed with Formula One, should be included wherever such constants are used.
To create a Dialog-based application select the Dialog radio button and click NEXT. Refer to Creating Dialog Box-Based Applications on page 2. To create a CFormView-based application select the Single Document or Multiple Documents radio button. Refer to Creating CFormView-Based Applications on page 3. To create a CView-based application select the Single Document or Multiple Documents radio button. Refer to Creating CView-Based Applications on page 3.
To add a Formula One component to your project in Visual C++ 5.0 or 6.0:
1. Choose Project > Add To Project > Components and Controls to display the Components and Controls Gallery dialog box. 2. Select the Registered ActiveX Controls folder.
3. If the Formula One Control icon is not visible in the list, then the control was not registered properly and you may need to reinstall or try to register it from the ActiveX Control Test Container, which is available in the Tools menu of Visual C++. 4. Select the control from the Component list and click Insert. Click OK. The Confirm Classes dialog box appears. 5. Click OK to confirm and exit the dialog box. 6. Click Close to exit the Component Gallery. The Formula One Control appears in the Control palette.
The MFC ClassWizard dialog box displays the variable in the Control ID window. 5. Click OK in the MFC ClassWizard dialog box to return to your project.
4. Now through the file list, display the C++ source file for the view (<projname>view.cpp). 5. Start the ClassWizard, and make sure the view class is selected as the Class Name. 6. Select the View object in the Object Id list. 7. Select the Create message in the Messages list. The Create handler initially presents the following code:
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
8. Start the ClassWizard, and select view class as the Class Name. 9. Select the View object in the Object Id list. 10. Select the WM_SIZE message in the Messages list. 11. Click the Add Function button to create the OnSize handler function for this message.
The guids (see italics above) are defined in TTF16.H and are:
CLSID_F1FileSpec CLSID_F1ODBCConnect CLSID_F1ODBCQuery CLSID_F1BookView
To use an API call to create an object, use the following code in Visual C++
5.0 or 6.0:
CF1CellFormat fmt(m_F1.CreateNewCellFormat());
To call a method that wants an object argument, use the following code in
Visual C++ 5.0 or 6.0:
m_F1.SetCellFormat(fmt.m_lpDispatch);
6. Run the program and when the document is clicked, the message You clicked on the workbook is displayed.
2. Select the Tidestone Formula One control from the list of available controls. 3. If the Tidestone Formula One component is not visible in the component list, click BROWSE to add the component. 4. Click OK. The Visual Basic form is returned, and the Formula One component appears in the Component palette. 5. Double-click the Tidestone Formula One icon in the component palette to drop it on your form. You can easily set specific properties for the Formula One component, either programmatically or through the Formula One property pages.
10
OLE 2 Presentation Style on page 10. This method inserts the Formula One control into the DataWindow and provides data via the DataWindow object. Uniform Data Transfer Method on page 14. This method simply places the Formula One control in the Application Window. Data is then copied to the clipboard where Formula One can access the data via the Uniform Data Transfer method. Standalone Worksheet Method on page 18. This method of using Formula One focuses on using it as a standalone spreadsheet without any database connectivity.
Database Preparation
Prior to creating an application in PowerBuilder that accesses a database, you must ensure that you have correctly configured your environment. The following sections outline some preliminary measures to take before working with databases in PowerBuilder.
11
5. If you must access a SELECT button or a BROWSE button to locate your database file, select the database file and click OK to return to the ODBC window. 6. Click OK to confirm the Setup dialog box information. 7. Click CLOSE.
12
6. Click OK. A message box appears prompting: Would you like PowerBuilder to generate an Application Template? 7. Click YES. 8. Click WINDOW to open a new window. The Select Window dialog box appears. 9. Select w_genapp_sheet from the list. 10. Click OK.
13
11. Click OK. The Formula One Workbook Properties dialog box appears. 12. Click OK to dismiss the Tidestone Formula One Control Properties dialog box. The Formula One control appears in your DataWindow, and the Ole Object dialog box appears. 13. Select the Data tab. 14. Drag and drop any key Source data to Target data in the appropriate order for assignment. By dragging this information to the Target data window, you are linking the database columns to the Formula One worksheet. 15. Click OK. 16. Right-click the DataWindow and choose Properties. 17. Select the General tab and enter the name of the DataWindow object in the Name text box. 18. Click PREVIEW to preview the DataWindow object and retrieve data from the database to display in Formula One. 19. Close the DataWindow and indicate Yes to save the changes. 20. Type in a name for your DataWindow object. 21. Click OK. 22. Select File > Close to close the DataWindow. 23. The DataWindow prompts you if you want to save changes. Click Yes.
14
The DataWindow control is now bound to the DataWindow object and acts as an interface to the database. 6. Click OK to accept the values and exit back to the DataWindow dialog box. 7. Click OK to dismiss the DataWindow dialog box.
Note dw_1 represents the default DataWindow control name; supply the name of your DataWindow control as created in the section titled Creating the DataWindow Object on page 16. 5. Click the Close box on the Script window. 6. Save the script when prompted. 7. Run your application.
15
The Select Application Library dialog box appears. 3. Type a filename in the text box. 4. Click SAVE. The Save Application dialog box appears. 5. Type an Application name. 6. Click OK. A message box appears prompting: Would you like PowerBuilder to generate an Application Template? 7. Click NO.
16
17
12. Drag and drop any key Source data to Target data in the appropriate order for assignment. By dragging this information to the Target data window, you are linking the database columns to Formula One. 13. Click OK. 14. Click PREVIEW to preview the DataWindow object and retrieve data from the database to display in Formula One. 15. Close the DataWindow and indicate Yes to save the changes. 16. Type a name for your DataWindow object. 17. Click OK. 18. Select File > Close to close the DataWindow. 19. The DataWindow prompts you if you want to save changes. Click Yes.
18
19
Working in PowerBuilder
Calling ActiveX Properties and Methods in PowerBuilder
The syntax to access an ActiveX property or method is as follows:
<Ole_Object>.object.<Ole Property or Method>
Property Example:
Ole_1.object.ShowGridlines (False)
Method Example:
Ole_1.object.SetSelection (1,1,5,5)
20
5. Find the ActiveX (OCX) control that you want to access. Under the ActiveX control is a list of Properties and Functions with the proper PowerBuilder syntax.
Converting 4.x or 5.x workbooks to 6.x workbooks is as easy as opening and saving a file. To open the file, use the File > Read menu command in the Workbook Designer, the File > Open command in the standalone Workbook Designer, or the Read or ReadEx methods in the API. Then save the file in 6.0 format in order to complete the conversion. To convert 2.0 workbooks, open the standalone Workbook Designer and use the File > Import > Formula One 2.x command. This menu command is only available on the standalone Workbook Designer. After importing the file, save it in the Workbook Designer using the File > Save command. This will save it in 5.0 format. Then you may open that 5.0 file and save it in the 6.x format.
Note You can no longer read in a Formula One 2.x file programmatically. You must use the standalone Workbook Designer to import it, as described above.
21
If you want to keep both versions of the software installed as components in your container, you will need to ensure that code that refers to objects specifies which version of the software you want to use. This is because the names of the objects are the same in both versions, so the container has no way of knowing which version you want. The following example, which uses the F1RangeRef object, specifies that the 6.0 version of the object should be used:
Dim Range As TTF160Ctl.F1RangeRef
Another way to fix this problem is to use either the 5.0 or the 6.x version of the software, but not both. For further information about upgrading from previous versions of Formula One, check the Tidestone website at www.tidestone.com.
Tidestone
23
C H A P T E R
Formula One provides a high-performance workbook control that allows you to create, manipulate, and print workbooks. Workbooks are objects that are drawn on a form or in a window of an application. You can also create invisible workbooks, which allow you to perform calculations or other functions without showing a workbook on a form or in a window. These objects are maintained by Formula One. Formula One also provides the Workbook Designer. The Workbook Designer provides a graphical interface that allows you to design and format a workbook for your application by pointing and clicking and using menu commands. The Workbook Designer is also available as a stand-alone application which allows you to create Formula One spreadsheets.
F1Book. A Formula One workbook object. An F1Book object is created when you place a Formula One workbook control on a form. F1BookView. A Formula One workbook view. An F1BookView object is a windowless, invisible workbook. It can contain data of its own, or it can be attached to a workbook, but have its own selection and view settings. F1FindReplaceInfo. A Formula One find/replace object. An F1FindReplaceInfo object contains properties and methods for find and replace operations.
24
Note The following objects hold data. They must be used in conjunction with F1Book or F1BookView methods to perform actions.
s
F1CellFormat. A Formula One cell format object. An F1CellFormat object contains properties that describe a cell format. F1EventArg. A Formula One event argument object. An F1EventArg object represents a reference to a variant value. F1FileSpec. A Formula One file spec object. An F1FileSpec object contains properties that describe a workbook file. F1NumberFormat. A Formula One number format object. An F1NumberFormat object contains properties that describe a number format. F1ObjPos. A Formula One object position object. An F1ObjPos object contains properties that identify the position of a specified object. F1ODBCConnect. A Formula One ODBC connect object. An F1ODBCConnect object describes an ODBC connection. F1ODBCQuery. A Formula One ODBC query object. An F1ODBCQuery object describes a query. F1PageSetup. A Formula One page setup object. An F1PageSetup object contains properties that describe the page setup for printing worksheets. F1RangeRef. A Formula One range reference object. An F1RangeRef object contains properties that identify a range of cells. F1Rect. A Formula One rectangle object. An F1Rect object contains properties that identify the rectangular area of a range or object on a worksheet. F1ReplaceResults. A Formula One replace results object. An F1ReplaceResults object contains properties that identify how many items have been found and how many have been replaced.
25
A workbook is a collection of individual worksheets.Worksheets allow you to show and analyze data. Data can be manipulated on several worksheets simultaneously, and you can base calculations on data from multiple worksheets. Worksheets are useful for organizing information into separate groups. For example, you might have the year-end sales figures for each sales region on a different worksheet within the same workbook. Having all the information in one worksheet can be cumbersome; splitting it into separate files makes working with the data inconvenient.
26
grid line display column and row heading display fixed row and column specifications maximum workbook viewing size
In addition, views can contain information about user permissions such as whether the user is allowed to select cells, enter or edit data, or resize rows and columns. The following illustrates the concept of one view showing data from one workbook.
Workbook
View
The view inherits the formatting and properties from the workbook.
When you update data and formulas in the workbook, they are reflected in the view, and vice versa.
A view is attached to a workbook by default; however, you can change the view to which the workbook is attached. Multiple views can be used to display specified data from one workbook, but each view can only display data from one workbook at a time. When multiple views are displaying data from the same workbook, any change made in one view is reflected in the other views. The following illustrates this concept.
27
View
View Workbook
View
The view should not be confused with the F1BookView API object. A view can only accommodate data from one workbook at a time. If you want to show one workbook that includes data from multiple workbooks, use the F1BookView API object, which is discussed in the following section.
28
The following example shows how you can use the F1BookView API object. In this example, data shown in the F1Book control changes according to the invisible workbook that is attached to this visible workbook. The calculations and data that are displayed do not require cut or clear commands so the user is less likely to notice changes to the visible workbook.
Visible workbook.
When this button is clicked, this invisible workbook is shown. When this button is clicked, this invisible workbook is shown.
The following code is used to create the invisible workbooks and perform the calculations. These variables are declared:
Dim bv1 As F1BookView Dim bv2 As F1BookView
29
actions and tasks the user can perform the appearance of the workbook and its worksheets the content and location of cells the selection status of cells the format of data
In general, most methods and properties that perform actions such as visually formatting a workbook or calling dialog boxes are not supported by the F1BookView object because it is an invisible workbook. Specifically, you cannot use the following properties and methods with the F1BookView object:
AllowDesigner CancelEdit DefinedNameDlg DoCancelEdit DoEndEdit DoObjDblClick DoObjValueChanged DoSafeEvents DoStartRecalc FileName FilePrintSetupDlg FindEx FormatCellsDlg BorderStyle ColorPaletteDlg DefRowHeightDlg DoClick DoEndRecalc DoObjGotFocus DoRClick DoSelChange DoTopLeftChanged FilePageSetupDlg Find FormatAlignmentDlg FormatDefaultFontDlg CalculationDlg ColWidthDlg DeleteDlg DoDblClick DoObjClick DoObjLostFocus DoRDblClick DoStartEdit Enabled FilePrintPreview FindDlg FormatBorderDlg FormatFontDlg
30
A view or F1BookView invisible workbook can be connected to only one workbook control at a time. An F1Book1 workbook control can have multiple views or F1BookView invisible workbooks to which it is attached. An F1Book1 workbook is always attached to a view. It ceases to exist if it is not attached to a view.
31
If the workbook contains multiple worksheets, you can specify which worksheet you want to display. This is accomplished by setting the Sheet property. Set Sheet to the index number of the worksheet you want to display. Sheets are indexed from left to right beginning with 1. Do not confuse the index with the worksheet sheet name that appears on the sheet tab. To prevent users from going to another worksheet in the workbook, you can set the ShowTabs property to F1TabsOff. This hides the sheet tabs, preventing the user from changing sheets. Alternatively, you could write code within the SelChange event to prevent the user from changing worksheets. You can limit the area of each worksheet that can be seen by setting the MinRow, MinCol, MaxRow, and MaxCol properties for each worksheet. This is particularly useful when you want to use multiple views to display different parts of the worksheet. The following illustration shows the property settings used to limit the number of rows that can be displayed in a view. The data displayed in all three views is contained in one worksheet. Notice that none of the views have vertical scroll bars. This is to prevent the end users from scrolling beyond the rows they already see.
MinCol = 1 MinRow = 2 MaxCol = 5 MaxRow = 7
32
Formula One 6.x does not support the Formula One 1.x or 2.x or Excel 4.x file formats. Since Formula One has some features not supported by Excel, files saved in the VTS file format cannot be read by Excel. The XLS format is based on records where each record represents a unique feature or property of the workbook. If the file you save contains features not supported by Excel, they are removed when the workbook is saved as an XLS file. Likewise, Excel contains features not supported by Formula One. Unsupported features are ignored when Formula One loads an Excel worksheet or workbook. Important If you load an Excel file that contains features not supported by Formula One, such as charts, drawing objects, or array formulas, those features are ignored. If the imported file is then written from Formula One as an Excel file and subsequently read by Excel, those features are omitted and irretrievable. Formula One cannot read password-protected Excel files. If you intend to read files from Excel, they should not be password-protected.
33
The following methods and properties are available for reading and writing files in Formula One applications:
Property/Method Read, ReadEx ReadFromBlob SaveFileDlg, SaveFileDlgEx Write, WriteEx WriteToBlob, WriteToBlobEx Description Reads a worksheet from disk.
34
WriteRange or WriteRangeEx. These methods write a range of cell data to a new file. InsertHTML. This method embeds a range of cell data into an existing HTML file at a specified anchor point.
35
C H A P T E R
The Workbook Designer is an interactive program that is available at design time, runtime, or as a standalone spreadsheet application. The Workbook Designer provides access to functions for designing and formatting a workbook by pointing and clicking and choosing commands from menus. The Workbook Designer allows you to manipulate a workbook control just like it was a part of spreadsheet application. The following illustration shows the Workbook Designer as it is displayed at design time or runtime.
Main Toolbar
Formula Bar
Drawing Toolbar
36
The following illustration shows how the Workbook Designer is displayed as a standalone spreadsheet application.
Drawing Toolbar
Main Toolbar
Formula Bar
Formatting Toolbar
Double-right click on the Formula One control and the Workbook Designer is displayed.
Double-click on TTF1.EXE in the Windows Explorer, or Select Start > Run and type the path to TTF1.EXE.
37
Calling this method displays the Workbook Designer, regardless of the setting of the AllowDesigner property. The following sections provide additional information about the Workbook Designer menus and toolbars.
If you drag it to an edge of the Workbook Designer, it is docked on that side of the Workbook Designer. If you drag and release the toolbar on top of the Workbook Designer, the toolbar is left floating.
File Menu
Command New Description Creates a new file. In the built-in version of the Workbook Designer, this action deletes any information currently in the Workbook Designer. The standalone Workbook Designer allows more than one workbook open at a time. Opens a workbook file from disk. Formula One can open files in the following formats: Formula One 3.0 or later (.VTS files), Excel 5.0 or later (.XLS files), and tabbed text (.TXT). Closes the Workbook Designer Saves the current worksheet. Formula One can save files in the following formats: Formula One 3.x, 4.x, 5.x, or 6.x (.VTS files), Excel 5.0, 95, or 97 (.XLS files), tabbed text or values-only tabbed text (.TXT), or HTML or data-only HTML (.HTM). Lets you import documents in the Formula One 2.x and Excel 4 file formats. In order for this to work, the developer or user must have a copy of Formula One 5.0 with a valid license key installed on his or her machine.
Import... (standalone)
38
Exit (standalone)
Edit Menu
Command Cut Copy Paste Paste Special Description Cuts the current worksheet selection to the clipboard. Copies the current worksheet selection to the clipboard. Pastes the contents of the clipboard to the current worksheet selection. Pastes the formats, values, or formulas of copied cells into selected cells. In addition, Paste Special controls how data copied from a different application is pasted. Copies the current cell formatting so you can apply it to another cell. Refer to the FormatPaintMode property in the Formula One on-line help for additional information. Toggles between normal polygon editing and polygon point editing. When polygon point editing is enabled, this command is checked. Selects all of the graphical objects on the active worksheet. Displays the Sort dialog box. This dialog box allows you to set the sorting method and sort keys for data sorting. Data in the top or leftmost cell is copied down or to the right to fill the range. Clears formats and values from the selected cells. Clears only formats from the selected cells. Clears only values from the selected cells.
Polygon Points
Select All Objects Sort Fill Clear > All Clear > Formats Clear > Contents
39
Removes the selected worksheets, and shifts the worksheets to the right of the deleted worksheets to the left. Searches in selected cells or sheets for the characters that you specify. It selects the first cell that contains those characters. Searches in selected cells or sheets for the characters that you specify, and replaces them with your specified replacement characters. Displays the Goto dialog box. This dialog box allows you to specify a cell to display in the worksheet window. The specified cell is made the active cell.
Replace
Goto
View Menu
Command Toolbar > Standard Toolbar > Drawing and Forms Formula Bar Status Bar Description Toggles the display of the Main Toolbar. Toggles the display of the Drawing Toolbar. Toggles the display of the Formula Bar. Toggles the display of the Status Bar.
Insert Menu
Command Cells Description Inserts cells at the location of the current selection. Cells adjacent to the insertion are shifted to make room for the new cells. Inserts a new row above the selected cell or row. Inserts a new column to the left of the selected cell or column. Inserts a new worksheet to the left of the selected worksheet. If more than one worksheets are selected, this command inserts the same number of worksheets that are selected. This command fails if non-contiguous sheets are selected. Inserts a First Impression chart on the active worksheet.
Chart
40
Name Drawing Object > Arc Drawing Object > Line Drawing Object > Oval Drawing Object > Polygon Drawing Object > Rectangle Forms Object > Button Forms Object > Checkbox Forms Object > Dropdown Listbox Cancel Insert Object
Format Menu
Command Cells Description Displays the Format Cells dialog box which allows you to set cell formatting such as numeric display, alignment, fonts, borders, patterns, protection, and validation. Displays the Row Height dialog box. This dialog box allows you to set the height of the selected rows, specify default row heights, and specify automatic row height. In addition, you can specify whether the selected rows are shown or hidden Hides the selected rows, which does not delete them from the worksheet. Shows the hidden rows in a selection. Displays the Row Height dialog box which allows you to define a default height of rows. Displays the Column Width dialog box. This dialog box allows you to set the width of the selected columns, specify default column widths, and specify automatic column width. In addition, you can specify whether the selected columns are shown or hidden. Automatically adjusts the width of all cells in the column to accommodate the size of a text string or value. Hides the selected columns, which does not delete them from the worksheet.
Row > Hide Row > Unhide Row > Default Height Column > Width
41
Displays the Column Width dialog box which allows you to define a default width of columns. Displays the Format Sheet dialog box which allows you to set properties for the active worksheet. Enables protection for protected cells in the worksheet. A check next to this command means that protection is enabled. Select the command again to disable protection. Freezes the selected columns or rows. Frozen columns and rows do not scroll and cannot be edited. Unfreezes frozen panes. Displays the Default Font dialog box. This dialog box allows you to set the default font used to display data in worksheets. In addition to setting the font and font size used to display data in a worksheet, the default font affects the widths of worksheet columns. Column widths can be set in units equal to 1/256th of the character 0 (zero) in the default font. Displays the Format Object dialog box, and includes the appropriate tabbed pages for the selected object. Places the selected objects in front of other objects in the worksheet. Places the selected objects behind other objects in the worksheet.
Tools Menu
Command Recalc Options Description Recalculates all open cells, worksheets, and workbooks. Accesses the Options dialog box. The Options dialog box includes tabbed pages for setting general, calculation, and color options.
A standard Window menu is provided on the standalone version of the Workbook Designer.
42
Standard Toolbar
Use the buttons on the Standard Toolbar to perform basic workbook functions such as opening, saving, and printing.
Button Name New Description Creates a new file.
Read
Save
Saves a file.
Prints the active worksheet. Displays the active worksheet in Print Preview mode. Cuts a selection to the clipboard.
Print Preview
Cut
Copy
Paste
Copy Format
43
Formatting Toolbar
Use the buttons on the Formatting Toolbar to quickly and easily format the data in the selected cell(s). This toolbar is available only with the standalone Workbook Designer. The Format Toolbar also provides drop-down lists that allow you to select fonts and font sizes.
Button Name Bold Description Controls the bold attribute for the currently selected range of data. Controls the italic attribute for the currently selected range of data. Controls the underline attribute for the currently selected range of data. Selects a color for the currently selected range of data. The color applies to the numbers and letters in the cell, not to the background or borders of the cell. Left aligns the selected range of data.
Italic
Underline
Color
Left Align
Center
Right Align
Right aligns the selected range of data. Merges the selected cells and centers the selected data. This is useful for straddling heading information across rows or columns. Displays a list of common fixed and general formats. Select a format to apply it to the selected range of data. Displays a list of common currency formats. Select a format to apply it to the selected range of data.
Currency
44
Fraction
Refer to Interactively Drawing Graphical Objects on page 124 in this manual for information about the icons on the Drawing Toolbar.
45
C H A P T E R
Workbook Fundamentals
Before you can successfully use a Formula One control, you must understand some basic concepts about the workbook. You must understand how to select worksheets, cells, ranges, rows, and columns, enter and delete data, and display specific sections of a workbook. This chapter discusses:
s
setting up workbook defaults adding, inserting, deleting, naming, selecting, and displaying worksheets navigating through a sheet with keyboard commands and with mouse actions selecting cells and ranges selecting entire rows and columns setting selection options
Setting up Workbooks
Formula One gives you options for customizing the display and the defaults used in the Workbook Designer. In most cases, you may use the preset defaults, but you may change them if you want using the options described below.
46
Click here to display or hide type markers, which are colored frames displayed inside cells to identify the contents. Blue type markers indicate blank formatted cells, green type markers indicate values or text, and red type markers indicate formulas.
2. Choose the options you want, as described above, and click OK.
Note You can hide the worksheet tabs in order to limit users to a single worksheet in a workbook that contains multiple sheets. Use the Sheet property to make the sheet you want users to access the active sheet.
47
Note By default, Formula One uses Arial as the default font. Be sure you always use a TrueType font as the default font in order for print and display scaling to work correctly.
A text sample with the font, style, and size you chose appears here. Some fonts provide scripts that allow you to use nonWestern alphabets. Choose the script you want here.
2. Choose the default font options you want. Click OK when you finish.
Use the SetDefaultFont method to set basic defaults. Use the SetDefaultFontEx method to set basic defaults and specify the character set.
48
Click here to return the selected color to its default value. Click here to return all the palette colors to their default values.
2. Double-click on the color you want to change. The Windows color editor will appear, allowing you to change the settings for the selected color.
Manipulating Worksheets
Once you create a Formula One workbook, you should understand how to add, insert, delete, name, and select the worksheets that are contained in your workbook. For additional information about workbooks and worksheets, refer to Understanding Workbooks and Worksheets on page 24.
49
The following illustration shows a Formula One workbook with three worksheets:
Drag this splitter bar to shrink or enlarge the sheet tab space.
Inserting Worksheets
By default, a workbook contains only one worksheet. You can easily insert additional worksheets via the Workbook Designer or program code.
50
Selecting Worksheets
Usually, you do most of your work in one worksheet at a time. This is called the active worksheet. When you have multiple worksheets in a workbook, you can use the mouse to click on a worksheets tab to make it the active sheet. The tab is highlighted and moves on top of the other tabs. You can save time and effort by performing some tasks on several sheets at once. For example, if you want all three worksheets in your workbook to have the same title information, you can select all three worksheets and enter the titles on the active worksheet. The titles are automatically entered in the corresponding cells in the other selected worksheets as well.
51
If you hold down the Shift key and select Sheet1, all sheets between the active sheet (Sheet4) and Sheet1 are selected.
If you select all but one sheet, and then make one of the selected sheets active by selecting it, all the other sheets remain selected.
If you hold down the Control key and select Sheet3, it is deselected, but the other sheets remain selected.
Use the SheetSelected property to toggle an individual worksheets selection status to on. The following example selects the second and third worksheets in the workbook:
SheetSelected (2) = True SheetSelected (3) = True
changing cell selection entering values via the formula bar inserting rows, columns, or ranges of cells deleting rows, columns, or ranges of cells clearing rows, columns, or ranges of cells setting TopLeft/Row/Column header text setting column width
52
Within your application code, the following methods and properties affect all selected worksheets:
Methods that affect all selected worksheets ClearRange DefColWidthDlg DeleteRange EditInsert FormatAlignmentDlg FormatFontDlg FormatSheetDlg MoveRange SetAlignment SetCellFormat SetFontEx SetProtection ValidationRuleDlg ColWidthDlg DefRowHeightDlg EditClear FilePageSetupDlg FormatBorderDlg FormatNumberDlg InsertDlg ProtectionDlg SetBorder SetColWidth SetPageSetup SetRowHeight CopyRange DeleteDlg EditDelete FilePageSetupDlgEx FormatCellsDlg FormatPatternDlg InsertRange RowHeightDlg SetBorderEx SetFont SetPattern SetValidationRule
Properties that affect all selected worksheets ColText Entry Formula FormulaLocalSRC HAlign Logical Number NumberRC ProtectionLocked Text TopLeftText ColWidth EntryRC FormulaLocal FormulaRC HdrWidth LogicalRC NumberFormat NumberSRC RowText TextRC VAlign EnableProtection EntrySRC FormulaLocalRC FormulaSRC HdrHeight LogicalSRC NumberFormatLocal ProtectionHidden RowHeight TextSRC WordWrap
53
Since Sheet2 and Sheet1 are selected, two additional worksheets are inserted to the left of Sheet2. Notice that the newly inserted worksheets are given the next available sheet names, regardless of their position in the sheet index list.
Use the NumSheets property to increase the number of worksheets in the workbook. Additional worksheets are added to the right of all existing worksheets. Use the InsertSheets method to add worksheets to the left of a specified worksheet. The following example illustrates how this method can be used to insert 2 worksheets to the left of the third worksheet in the workbook:
F1Book1.InsertSheets 3, 2
Use the SheetSelected property to select the number of worksheets you want and then use the EditInsertSheets method. The following example selects the third and fourth worksheets in the workbook and inserts two worksheets before the third worksheet.
F1Book1.SheetSelected (3) F1Book1.SheetSelected (4) F1Book1.EditInsertSheets
54
Deleting Worksheets
You can delete one or more worksheets from the sheet index list through the Workbook Designer or through application code.
Use the NumSheets property to decrease the total number of worksheets. Worksheets are deleted from the right. Use the DeleteSheets method to delete specific worksheets. The following example uses this method to delete the third and fourth worksheets from the workbook:
F1Book1.DeleteSheets 3, 2
Use the SheetSelected property to select sheets and then use the EditDeleteSheets method. The following example selects the first and fourth worksheets and then deletes them:
F1Book1.SheetSelected (1) F1Book1.SheetSelected (4) F1Book1.EditDeleteSheets
55
Renaming Worksheets
Formula One provides a default name for each worksheet. You can change the names to more meaningfully describe the sheets contents. For example, the sheet names in the following illustration are more descriptive than the worksheets default names.
Double-click the sheet tab to display the Sheet Name dialog box.
Use the SheetName property to rename a worksheet identified by index. The following code changes the name of the second worksheet in the workbook to QTR 2 Sales.
F1Book1.SheetName (2) = "QTR 2 Sales"
56
Finally, you may specify how you want to display formulas and zero values.
To display zeroes in cells, select this option. To leave cells with zero values empty, unselect this option.
To display formulas, select this option. To display values that the formulas calculate, uncheck this box. When formulas are displayed, Formula One automatically doubles the width of columns to accommodate the wider text. When the Formulas option is later unselected, column widths return to their original settings.
3. Select the worksheet and data viewing options you want by selecting or unselecting the options in the Sheet and Data values. 4. To display the worksheet larger or smaller than its actual size, enter a value from 10 to 400 in the View Scale box. 5. To display fewer than the maximum number of rows and columns, enter the range that you want to display, in absolute references, in the Sheet Limits box. 6. Click OK.
Use the ShowFormulas, ShowGridLines, ShowZeroValues, ShowRowHeading, ShowColHeading, ViewScale, MaxRow, and MaxCol properties.
57
Wheel-click (on the Invokes or cancels scrolling mode, which allows users to IntelliPoint mouse) or middle scroll by moving the mouse over the worksheet. To disallow click scrolling mode, hide the scroll bars using the ShowHScrollBar and ShowVScrollBar properties. Left-Click in Row or Column Selects entire row or column. Headings Left-Click in Top Left Corner Selects entire sheet. Left Double-Click in Top Left Displays a dialog box that allows you to enter a label for the Corner, Row Headings, top left corner or the column or row heading, or a new name Column Headings, or for the worksheet that was double clicked. Worksheet tabs Left Double-Click Right Double-Click In the Workbook Designer, invokes in-cell editing. At run time, a DblClick event is fired. In the Workbook Designer, does nothing. At run time, the Workbook Designer is launched if DoRDblClick is False. Left-Click and Drag Selects a range. If other ranges are selected, the previously selected ranges are unselected.
CTRL + Left-Click and Drag Selects a range. If other ranges are selected they remain selected. SHIFT + Left-Click and Drag Extends the current selection. CTRL + SHIFT Click on Row Selects the row headings, column headings, or top left corner Headings, Column Headings, of the sheet. or Top Left Corner Drag a Selection's Copy Handle Drag a Selections Border ALT + Click and Drag an Object or Objects Selection Handles Copies the selection into the newly selected area. Moves the selection to a new location. Repositions or resizes an object and aligns object sides with the cell grid.
58
position the active cell in the worksheet page through a worksheet enter data typed in a cell move the active cell within a selected range enter and exit edit mode recalculate a workbook delete data from a selected cell or range
The tables in this section list the keyboard commands you can use when working in the Workbook Designer or a workbook at run time. The following table lists action keys that allow you to enter and edit data, move the active cell within a selected range, and recalculate the workbook.
Key ENTER Description When in edit mode, accepts the current entry. When a range is selected, and if the EnterMovesDown property is set to True, accepts the current entry and moves active cell vertically to next cell in selection. When in edit mode, accepts the current entry. When a range is selected, and if the EnterMovesDown property is set to True, accepts the current entry and moves active cell vertically to previous cell in selection. When in edit mode, accepts the current entry and moves the active cell horizontally to right. When in edit mode, accepts the current entry and moves the active cell horizontally to left. Enters edit mode. While in editing mode, F2 displays the Cell Text dialog box, in which you can enter multi-line data entries. Recalculates workbook. May clear current selection depending on the setting of the AllowDelete property. Cancels current data entry or editing operation.
The following table lists the movement keys that allow you to move the active cell within a worksheet and display different sections of the workbook.
Key Up Arrow Down Arrow Left Arrow Description Moves active cell up one row. Moves active cell down one row. Moves active cell left one column.
59
Moves to the next range of cells containing data. If there is no additional data in the direction in which you are moving, moves to the edge of the worksheet. Moves up one screen. Moves down one screen. Activates the previous worksheet in the current workbook. Activates the next worksheet in the current workbook. Goes to first column of current row. Goes to last column of current row that contains data. Goes to row 1 column 1. Goes to last row and column that contains data.
The following table lists the keys that modify the action of the movement keys.
Key Scroll lock SHIFT plus any movement key Description Causes the view window to scroll without changing current selection with all movement keys except Home, End, CTRL Home, and CTRL End. Extends the current selection.
60
Selecting Cells
Many operations require one or more cells to be selected. There are three kinds of selections: a single cell, a range of cells, and multiple ranges of cells (non-adjacent). The following illustration shows the three types of selections.
Single cell selection
To select a range of cells, click and hold the left mouse button and drag through the range you want to select. When a range is selected, it becomes highlighted. To select multiple ranges, press the CTRL key while selecting a range with the mouse. Any previously selected ranges remain selected.
Once a range is selected, you can move the active cell within the range using the ENTER, SHIFT + ENTER, TAB, and SHIFT + TAB keys. When you use these keys to move the active cell, the range remains selected.
61
Setting the Selection property removes all current selections and selects a range. The AddSelection method adds a selection to the current selection list. Continue calling AddSelection to create multiple selections.
The following example selects two ranges. The range my_select is selected, which is the name for A1:D4, and then the E5:H8 range is added.
F1Book1.Selection = "my_select" Select A1:D4 F1Book1.AddSelection 5, 5, 8, 8 add e5:h8
The value of the SelectionCount property tells you the number of selections. You can use this if a selection is made by the user and you need to determine how many ranges are selected. The value of the Selection property gives you all current selections in the form of a formula (e.g. A1:D4,E5:H8). The SelectionEx property used with the F1RangeRef API object returns the row and column of the specified selection.
The following example returns the value of a specified selection and adds another column to the selection.
Dim sel As F1RangeRef Dim cnt As Integer For cnt = 0 To (F1Book1.SelectionCount - 1) Set sel = F1Book1.SelectionEx(cnt) F1Book1.AddSelection sel.StartRow, sel.StartCol, sel.EndRow, sel.EndCol + 1 Next cnt End Sub
62
To prevent users from selecting cells, rows, columns, graphical objects, or worksheets, uncheck this option. To prevent users from selecting graphical objects, uncheck this option.
To specify that the entire row should be selected whenever an individual cell in that row is selected, check this option.
3. Choose the selection options you want. Click OK when you are done.
63
C H A P T E R
Entering and manipulating data is the basis for nearly all work performed in a workbook control. You can enter virtually any type of data and formula. With formulas and built-in functions, you can evaluate and calculate that data and make decisions based on the results of those operations. This chapter discusses:
s
how to enter data directly or with methods and properties how to use autofill lists the types of constant values that can be entered how to construct and use formulas the suite of built-in worksheet functions using names the methods for calculating worksheets how to limit user data entry
Direct entry. This is the most direct method of data entry. Data can be entered directly in a worksheet at run time. Or, you can enter data in the Workbook Designer at design time. Properties and methods. Several properties and methods allow you to enter data in the active cell or a specified cell.
64
The formula bar appears by default in the Workbook Designer, and you can turn on or off the display of the formula bar and cell reference indicator in your workbook control.
Select View > Formula Bar to toggle the display of the formula bar.
Set the ShowEditBar property to True. If the ShowEditBar property is True, you can also set the ShowEditBarCellRef to True to display the cell reference indicator with the formula bar.
Important The formula bar does not appear on the control unless the container makes it UI Active (provides a window for it).
65
FormattedTextSRC Sets or returns the value of the specified cell as it appears in the worksheet. Formula FormulaLocal FormulaLocalRC Sets or returns the formula in the active cell. Sets or returns the text version of the formula in the active cell, in the users language. Sets or returns the text version of the formula of the specified cell, in the users language.
FormulaLocal SRC Sets or returns the text version of the formula of the specified cell, in the users language. FormulaRC Logical LogicalRC Logical SRC Number NumberRC Number SRC Text TextRC TextSRC Sets or returns the formula in the specified cell. Sets or returns the formula in the active cell. Sets or returns the logical value of the specified cell. Sets or returns the logical (True or False) value of the specified cell. Sets or returns the numeric value of the active cell. Sets or returns the numeric value of the specified cell. Sets or returns the numeric value of the specified cell. Sets or returns the text value of the active cell. Sets or returns the text in the specified cell. Sets or returns the text value of the specified cell.
When entering data interactively in the Workbook Designer or in a worksheet at run time, press F2 when editing a cell. The Cell Text dialog box is displayed in which you can enter the cell data. To enter a line feed, press RETURN. Click the OK button to accept the entry and return to normal worksheet editing. When entering data with properties or methods, you should specify line feeds with the ANSI character code 10.
After entering multi-line data, you may need to resize the row and column in which the entry is placed in order to view all the data. The following example uses the TextRC property to enter three lines of data in cell A1.
F1Book1.TextRC(1,1) = Regional Sales & Chr$(10) & FY 94 & Chr$(10) & Q2
66
The multi-line entry is placed in cell A1. Row 1 and column A have been resized so the entry is not cropped.
You can also enter multi-line row and column headers. Refer to Formatting Row and Column Headings in Chapter 7 for information about entering and formatting row and column headers.
Constant values are numbers (including dates and times), logical values, error values, and text. Formulas are groups of constant values, cell references, names, functions, and operators that result in a new value when calculated or evaluated.
Negative numbers can be preceded by a minus sign or enclosed in parentheses. Commas can be included in numeric entries as thousands separators. Numeric entries containing leading dollar signs (or other currency signs, such as for pounds) are formatted as currency. Numeric entries containing trailing percent signs are formatted as percentages.
Formula One accepts numeric entries as fractions. If the fraction contains a leading integer (e.g., 1 1/3) it can be entered directly. If there is no leading integer, the fraction should be preceded by a zero (e.g., 0 2/3). Numbers larger than the cell in which they are entered are converted to scientific notation unless a specific format is applied. Use the SetColWidthAuto method to automatically set the column width to the correct size for all data in the column. The following code automatically sets the widths of columns 1 through 10.
F1Book1.SetColWidthAuto -1, 1, -1, 10, False
67
Dates and Times. Dates and times are automatically recognized by Formula One. They are entered in the cell as values and automatically formatted. The following date and time formats are automatically recognized.
Entered 3/15/94 15-Mar-94 15-Mar Mar-94 9:55 PM 9:55:33 PM 21:55 21:55:33 3/15/94 21:55 Format Assigned m/d/yy * d-mmm-yy d-mmm mmm-yy h:mm AM/PM h:mm:ss AM/PM h:mm h:mm:ss m/d/yy h:mm *
* These formats are locale-dependent. For example, in the United Kingdom, 15/3/94 would be recognized as the date format d/m/yy. Text. Text is any set of characters that Formula One does not recognize as a number, date, or time. Text that is wider than a cell ordinarily spills over into the cell immediately to the right. You can specify that text should wrap within the cell by enabling word wrap in your alignment format settings. Logical and Error Values. Logical and error values are not normally entered directly in cells; they are usually the result of a formula. However, entering these values can be useful for testing formulas. The logical values that can be entered are TRUE and FALSE. The error values that can be entered are #N/A, #VALUE!, #REF!, #NULL!, #DIV/0!, #NUM!, and #NAME?.
Entering Formulas
Formulas are the basic building blocks for analyzing and calculating worksheet data. A formula is a string containing numbers, operators, worksheet functions, cell references, and names. A formula can contain as many as 1024 characters.
s
When you manually enter a formula in a worksheet, you must begin the entry with an equal sign (=). Formula One recognizes this entry as a formula. When entering a formula using the Formula, FormulaRC, and FormulaSRC properties, exclude the leading equal sign. These entities expect strings.
Numbers in formulas can be followed by a percent sign (%). Numbers with trailing percent signs are treated as percentages (e.g., 100% is evaluated as 1).
68
If text is encountered when a number is expected, the text is converted to a number. For example, the formula 1 + 3 returns 4, because 3 is converted to a number. If the text cannot be converted to a valid number (e.g., 1 + Text), #VALUE! is returned. Likewise, if a number is encountered when text is expected, the number is converted to text. The formula The number is &3 converts to the text string The number is 3. The value TRUE always converts to 1; FALSE converts to 0. If a number is encountered when a logical value is expected, a zero is converted to FALSE. All other numbers are converted to TRUE. If text is encountered when a logical value is expected, TRUE is converted to TRUE; FALSE is converted to FALSE. All other text returns #VALUE!. Dates and times are recognized and converted to their serial values. For example, 10/10/94 - 10/1/94 equals 9.
69
Operators of like precedence are evaluated left to right. Parentheses should be used when it is necessary to change the order of evaluation. The following example illustrates how the result of a formula can be altered by adding parentheses to change the order of precedence.
Formula 1+2*37 (1+2)*37 Result 75 111
As illustrated in the previous table, the multiplication operator (*) has higher precedence than the addition operator (+). It is evaluated first unless parentheses are used to force the addition to take place first.
70
Relative references point to a cell based on its relative position to the current cell. When the cell containing the reference is copied, the reference is adjusted to point to a new cell with the same relative offset as the originally referenced cell. Absolute references point to a cell at an exact location. When the cell containing the formula is copied, the reference does not change. Absolute references are designated by placing a dollar sign ($) in front of the row and column that is to be absolute.
References can be part absolute and part relative. These are called mixed references. The following table lists the reference types.
Reference A1 $A$1 $A1 A$1 Type Relative reference pointing to cell A1. Absolute reference pointing to cell A1. Absolute column reference, relative row reference pointing to cell A1. Relative column reference, absolute row reference pointing to cell A1.
The reference operators can be used to specify multiple ranges in the same reference. For example, A1:C1,A10:C10 specifies the three cells A1, B1, and C1 and the three cells A10, B10, and C10. The formula =SUM(A1:C1,A10:C10) adds the values in all six cells.
Workbooks are referenced by the value of their Title property, and must be loaded in another control for the reference to work.
71
Important Worksheets must be referenced in index order. For example, the reference to the sheet indexed 1 must come before the reference to the sheet indexed 2. Remember that the worksheet index is usually different that the sheet name that appears on the sheet tab. Worksheets are indexed from left to right, beginning with 1. The following syntax references the range A1 to B2 in Sheet1 and the range A1 to B2 in Sheet2.
Sheet1:Sheet2!A1:B2
You can also reference multiple worksheet ranges in different workbooks by referencing the workbook name at the beginning of the syntax.
[F1Book1]Sheet1:Sheet2!A1 [SSView2]Sheet1:Sheet2!A1:B2
External References
References can point to cells in other workbooks. This type of reference is called an external reference. An external reference is created by placing a workbook name in brackets, followed by the worksheet name and an exclamation point, and finally a cell reference. The following table shows examples of external references.
Reference [Sales]Sheet1!A1 [FY91]Sheet2!$A$1 [Q1]Sheet1:Sheet2!$A1 Type Relative reference pointing to cell A1 in the first worksheet of a workbook titled Sales. Absolute reference pointing to cell A1 in the second worksheet of a workbook titled FY91. Absolute column reference, relative row reference pointing to cell A1 in the first and second worksheets in a workbook titled Q1. Relative row and column reference, pointing to the range A1 to F1 in a workbook titled Store1.
[Store1]Sheet1:Sheet4!A1:F1
72
#REF! #VALUE!
Displaying Formulas
It is often convenient to display formula text instead of the values they produce. Setting ShowFormulas to True, causes the worksheet to display formula text instead of formula results. Displaying formula text can help you debug formula- related problems. The following example enables and disables the display of formulas.
F1Book1.ShowFormulas = TRUE Displays formulas F1Book1.ShowFormulas = FALSE Displays formula text
73
Worksheet functions:
s
calculate and evaluate data can be used alone or in a formula are entered directly in the worksheet
Like formulas, worksheet functions return data to the cell in which they are entered. Each function performs a specific calculation. The SQRT function is an example of a built-in function. With this function, you can easily calculate the square root of a number. The following example calculates the square root of 118:
=SQRT(118)
Understanding Functions
Most worksheet functions are composed of keywords and arguments. Every worksheet function contains a keyword, but not all functions require arguments.
s
The keyword identifies the function and tells the worksheet what type of calculation or evaluation is performed. Each function keyword is unique. Arguments provide the data for the function to calculate or evaluate. The arguments for a function immediately follow the function keyword and are enclosed in parentheses.
Entering Functions
When entering functions in a worksheet, all functions are preceded by an equal sign (=). The leading equal sign tells the worksheet that the following information is to be evaluated or calculated. The function keyword follows the equal sign. It can be entered in lowercase or uppercase characters. After the function is entered, the worksheet records the function keyword in uppercase characters, regardless of how it was entered. If a function requires multiple arguments, the arguments are separated by commas. Some functions contain optional arguments. If you omit an optional argument, a default value is assumed for the argument. Functions that do not require arguments still require a set of parentheses following the function keyword.
Nesting Functions
A function can be used as an argument for another function. When a function is used in this manner, you are nesting functions. The nested function must return the appropriate type of data for the function in which it is nested. You must also provide the necessary arguments for the nested function.
74
In the following example, the AVERAGE function is used as an argument for the SUM function. In this case, AVERAGE is nested in SUM.
=SUM(5.23, 6.82, AVERAGE(2.45, 5.62, 7.74), 8.95, 9.01)
Entering Arguments
The arguments for a function can be:
s
Numerical values Logical values Text strings Error values References to cells or ranges
Each argument requires a specific type of data. Refer to Chapter 14, A-Z Worksheet Function Reference, to determine the type of data required for the function you are entering. For most arguments, you can substitute a cell or range reference for the data required by an argument. For example, if an argument requires a number, you can substitute a reference to a cell that contains a number. The number in the referenced cell is used in the calculation of the function. The data in the referenced cell must be appropriate for the argument for which it is used.
Syntax Errors
If the worksheet function you enter contains syntax errors, Formula One does not allow the function to be entered. You must correct the errors before proceeding with other tasks.
75
Once Formula One has recognized the text as an item from an autofill list, pressing Tab puts the next list item in the next cell to the right, or Enter puts the next list item in the next cell below.
Use the AutoFillItemsCount method to determine the number of autofill lists. Then increment by one and use the AutoFillItems property to specify the new list. The following example illustrates:
F1Book1.AutoFillItems (F1Book1.AutoFillItemsCount+1) = "A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z"
Note Values recognized as data cannot be used as autofill list items, such as 1973;1974, 1a;1b, 1%;2%.
When (New List ) is selected, you can type your custom list in the Current List text box. You can also edit default lists using this text box.
3. Select (New List) from the Lists list. 4. Type your new autofill list in the Current List text box, separating each item with a semi-colon. 5. Click Add.
76
Get the current string of text that makes up a list by returning the value of the AutoFillItems property.
list = F1Book1.AutoFillItems(2)
Using Names
User-defined names are an easy way to identify a cell, a group of cells, a value, or a formula. For example, the formula = Sales - Expenses is much clearer than A10 - A6. You can also use names to identify constants and formula expressions. For example, you might define the name LightSpeed as 186000. You could then use the name LightSpeed in all your formulas. Or, you could define the name SqRtTwo as the formula SQRT(2).
Use the DefinedName property. The following code uses this property to define a name.
77
This example defines the name Sales as $A$10. The name Sales can then be used in formulas instead of the reference. Formula One has a set of built-in names. These names are used by the print functions. The built-in names are listed in the following table.
Built in Name Print_Area Print_Titles Purpose Defines the print area used during printing. This name can contain one or more ranges (e.g., A1:C3,A11:C13). Defines the row and column titles that are printed on each new page. Entire rows and columns must be selected when you define this name.
Calculating Worksheets
Formula One calculates cells in natural order. In natural order calculation, formulas are calculated in such a way that all dependencies are calculated before their dependents. This ensures that the formula results are always correct. When a worksheet is edited, Formula One first adjusts formula references so they point to the correct cells. Then, Formula One determines the natural order of the formulas. When a change is made to a cell, the formulas are recalculated to keep all worksheets in the workbook current, ensuring that data is always valid.
78
2. Select the Automatic Recalc option to turn auto recalc on, or unselect it to turn it off. 3. Click OK.
The following code uses the AutoRecalc property to disable the automatic recalculation setting.
79
80
3. In the Maximum Iterations text box, type the maximum number of iterations you want Formula One to execute. 4. In the Maximum Change text box, type the maximum change between iterations. The smaller the number, the more accurate your answer is. 5. Click OK.
4. Unselect the following options: Enable Delete Key, Enable In-Cell Editing, Enable Cell Text Dialog, and all of the options in the Allow User To box. 5. Click OK.
81
Set all of the following properties to False: ShowEditBar, AllowDelete, AllowInCellEditing, AllowCellTextDlg, AllowResize, AllowFillRange, AllowMoveRange, AllowEditHeaders, and AllowFormulas. Data and formula entry and editing is thus prevented. Any data manipulation must be performed programmatically.
82
Note Worksheet cells are locked by default. If you want to protect only selected cells, you must unlock the rest of the worksheet cells, then enable worksheet protection.
To use the Workbook Designer to deny access to row and column headings:
1. Select the worksheet(s) you want to restrict access to headings in. 2. Choose Format > Sheet > Properties and click the Edit tab. The Edit tab, shown on page 80, will appear. 3. Uncheck the Edit Headings box and click OK.
83
Note Validation rules are only checked if data is entered manually, or through use of the Entry or EntryRC property. Any other way of entering data, such as selecting a value from a check box, bypasses validation.
Note Formula Ones validation rules are incompatible with Microsoft Excels validation rules.
This illustration shows the validation rule created for cell A1.
84
This illustration shows the message displayed when the data entered in cell A1 fails the validation rule.
Use the ValidationRule property of the F1CellFormat object to create, edit, or return the validation rule associated with the specified cell. (You can also use the ValidationRuleLocal, ValidationRuleRC, and ValidationRuleLocalRC properties to set or return validation rules.) Use the ValidationText property of the F1CellFormat object to create, edit, or return the text to be displayed if the validation rule fails. Use the FormatCellsDlg method to display the Format Cells dialog box. For example, to only display the Validation tab of the Format Cells dialog box, use the following code:
F1Book1.FormatCellsDlg (64)
Use the ValidationFailed event to respond progammatically when data fails. You can even change the value of the data within the ValidationFailed event and attempt to re-validate.
All of these properties, methods, and events are documented in detail in the Formula One Online Documentation.
85
To use the Workbook Designer to deny users the ability to enter formulas:
1. Select the worksheet(s) in which you dont want users to enter formulas. 2. Choose Format > Sheet > Properties and click the Edit tab. The Edit tab, shown on page 80, will appear. 3. Uncheck the Enter Formulas box and click OK.
To use properties and methods to deny users the ability to enter formulas:
s
Set the AllowFormulas property to False. Setting this property to False does not affect the entry and editing of constant values.
86
87
C H A P T E R
Editing Worksheets
You can copy, move, and paste selections interactively or programmatically. Methods allow you to insert data in and delete data from ranges, rows, and columns. A selected range of data can be sorted according to keys that you specify.
Formulas. Establish the value in a cell. Formulas are displayed in the formula bar when the cell is active. Values. What displays in the cell. Formats. How the cells and values are shown, such as red text applied to a selection.
Note Formula One maintains its own internal clipboard and also supports text on the Windows clipboard. The internal clipboard is more flexible than the Windows clipboard. The internal clipboard retains formulas and allows cell references to be adjusted when cells are pasted. The Windows clipboard only holds text and formatting; cell references are not maintained by the Windows clipboard.
copy a selection to the right or down using dragging drag-and-drop a selection to copy or move it
88
In this illustration, the number in A1 is copied to the cells below when the copy handle is dragged downward.
You can also copy a selected range in a worksheet. If an autofill list is defined for the data in the range, the data is copied using the autofill list, as shown in the following illustration.
In this illustration, the cells below the range are filled with the data from the autofill list when the copy handle is dragged downward.
89
When placed on the selection border, the pointer changes to an arrow, as shown in the following illustration.
to move the selection, hold down the mouse button and drag-and-drop the selection to the new location. to copy the selection, hold down the CTRL key and drag-and-drop the selection to the new location
An outline of the selection moves as you drag the pointer, as shown in the following illustration.
When you dragand-drop a selection border, the highlighted area moves to indicate the placement of the selection.
Tip To place the selection on an area of the worksheet that is not visible, move the cursor to the edge of the worksheet and scroll to the appropriate location. 4. When the pointer is at the appropriate location, release the mouse button. The original selection is not moved if you hold down the CTRL key. However, The original selection is moved to the new location if do not hold down the CTRL key. Note You can disable the users ability to copy data by setting the AllowFillRange property to False. This disables interactive data copying.
90
To drag information from another application and drop it into Formula One:
1. Arrange the application windows so that the source and destination documents are open and visible. You must be able to see the information you want to drag and the Formula One worksheet you want to place it on. 2. Select the information you want to move or copy.
s
To move the information, point to the selected information, and then hold down the mouse button. When the pointer appears, drag the pointer to the new location, and then release the mouse button. The pointer changes to to indicate a move. To copy the information, hold down the CTRL key, point to the selected information, and then hold down the mouse button. When the pointer appears, drag the pointer to the new location, and then release both the mouse button and the CTRL key. The pointer changes to to indicate a copy.
To move the selection, point to it, and then hold down the mouse button. When the pointer appears, drag the pointer to the new location, and then release the mouse button. The pointer changes to to indicate a move. To copy the selection, hold down the CTRL key, point to the selection, and then hold down the mouse button. When the pointer appears, drag the pointer to the new location, and then release both the mouse button and the CTRL key. The pointer changes to to indicate a copy.
91
move, or copy and paste a selection copy formatting of a selection and apply it to a cell or range paste individual attributes of a selection to another location
Formula One also provides toolbar buttons that perform the same functions as the menu commands.
Select the option button for the attribute that you want to paste.
2. Click OK.
92
EditCut EditPaste
EditPasteValues
EditPasteSpecial
If you cut a cell to which formulas refer, the formula references are maintained while the cell remains in the clipboard. If the cell is subsequently pasted, references in the original formulas are adjusted to point to the cells new location. If a cell containing a formula is copied and subsequently pasted, its relative references are adjusted to point to a new location.
93
The CopyDataFromArray method allows you to quickly copy data from an array to a specified range of cells in a worksheet. The CopyDataToArray method allows you to quickly copy data from a specified range of cells in a worksheet to a variant array.
94
The Find dialog allows you to search for data in a worksheet by row order or by column order.
In a Formula One worksheet, you can search for data in cell Values or Formulas.
3. Enter the data you want Formula One to search for in the Find What dialog box. Choose any special search options you want, then click the Find Next button. 4. Formula One will select the first cell that contains the search string you chose. If it finds no instances of the string, it will display the message "Cannot find matching data." 5. If you want to replace the data, click Replace. The Replace dialog box, shown below, will appear. 6. Click Close when you finish.
95
2. Choose Edit > Replace or issue the Ctrl H keyboard shortcut. The Replace dialog, shown below, will appear.
The Replace dialog provides a text box for entering the data string you wish to replace with.
Select Match Case if you want the search to find data with matching case. Select Find Entire Cells Only if you want the search to locate cells containing only the string. Otherwise, Formula One will also locate cells that contain the search string and other data.
3. Enter the data you want Formula One to search for in the Find What dialog box. Enter the data you want to replace that data with in the Replace With box. Choose any special search options you want, then click Find Next. 4. Formula One will select the first cell that contains the search string you chose. If it finds no instances of the string, it will display the message "Cannot find matching data." 5. Click Replace if you want to replace the data, or click the Find Next button to search for the next instance of the search string. 6. Click Close when you finish.
96
For more information regarding find and replace objects, properties, and methods, review the sections on the F1FindReplaceInfo object in the Formula One on-line help.
Use the InsertRange method to insert new cells in a worksheet. You supply a range where new cells are inserted and specify how the current cells in that range should be shifted to make room for the new cells. The following example inserts a two by two block of cells starting at B2. The current cells in the range B2:C3 are shifted downward to make room for the new cells.
F1Book1.InsertRange 2, 2, 3, 3, F1ShiftVertical
Use the EditInsert method to insert cells, rows, and columns. You specify whether rows, columns, or cells should be inserted. This method call uses the currently selected range to determine how many rows, columns, or cells to insert.
When new cells are inserted, cell references in formulas are adjusted so the formulas remain correct.
97
The next four examples assume the range A4:B5 is selected (a two by two range). In the following code, data in all columns and rows 4 and below is shifted down two rows to allow room for the inserted cells.
F1Book1.EditInsert F1ShiftRows
The following code shifts all data in the worksheet right two columns to allow room for the inserted cells.
F1Book1.EditInsert F1ShiftCols
In the following code, data in all columns of rows 4 and 5 is shifted right two columns to allow room for the inserted cells
F1Book1.EditInsert F1ShiftHorizontal
In the following code, data in columns A and B in rows 4 and below is shifted down two rows to allow room for the inserted cells
F1Book1.EditInsert F1ShiftVertical
98
Operation Deletes the current selection. Deletes the specified range. Clears the current selection. Clears the specified range.
EditDelete is similar to the EditInsert method. For EditDelete, you specify whether cells, rows, or columns should be deleted. The number of cells, rows, or columns deleted is determined from the current selection. For example, to delete rows (based on the current selection), you could use the following code:
F1Book1.EditDelete F1ShiftRows
If you delete cells (e.g., using EditDelete or DeleteRange) to which a formula refers, those formulas return a #REF! error because the referenced cells no longer exist.
s
To delete a specific range instead of the current selection, use the DeleteRange method. This method allows you to explicitly specify the range to delete. The following code uses this method.
F1Book1.DeleteRange 1, 1, 3, 3, F1ShiftRows
Clearing a cell can clear the value or format in a cell, or both. You can also specify whether or not formulas are cleared. Clearing does not shift other cells in the worksheet. The cleared cell has a value of zero. Formulas that refer to cleared cells obtain a value of zero from those cells.
s
You can use EditClear or ClearRange to clear a cell or range of cells. The following example clears the current selection.
F1Book1.EditClear F1ClearAll
Alternately, you can use the following example to clear specific rows or columns instead of the current selection.
F1Book1.ClearRange 1, 1, 3, 3, F1ClearAll
99
C H A P T E R
Formatting Worksheets
Formula One supports a rich set of data formatting capabilities. You can use number formats to display numbers in a certain way -- as dates, for example, or as dollars. You can use cell formats to change the size of cells and to add colors and borders. You can use font formats to change the typeface and style of the characters in your worksheet.
100
The following table shows the built-in number formats for a US English locale and the result after the format is applied to a positive, negative, and decimal number.
Category and Format General Currency $#,##0_);($#,##0) $#,##0_);[Red]($#,##0) $#,##0.00_);($#,##0.00) $#,##0.00_);[Red]$(#,##0.00) _($* #,##0_);($* #,##0);_($* "-"_) ;_(@_) _($* #,##0.00_);($* #,##0.00);_($* "-"??_) ;_(@_) Fixed 0 0.00 #,##0 #,##0.00 #,##0_);(#,##0) #,##0_);[Red](#,##0) #,##0.00_);(#,##0.00) #,##0.00_);[Red](#,##0.00) _(* #,##0_);(* #,##0);_(* "-"_);_(@_) _(* #,##0.00_);(* #,##0.00);_(* "-"??_) ;_(@_) Percent 0% 0.00% Fraction # ?/? # ??/?? Scientific 0.00E+00 ##0.0E+0 $3 $3 $3.00 $3.00 ($3) ($3) in red ($3.00) ($3.00) in red ($ ($ 3) 3.00) -3 -3.00 -3 -3.00 (3) (3) in red (3.00) (3.00) in red ( ( 3) 3.00) -300% -300.00% -3 -3 -3.00E+00 -300.0E-2 $ $ $0 $0 $0.30 $0.30 3 3 -3 -3 .3 .3
$ $
3 3.00 3 3.00 3 3.00 3 3 3.00 3.00 3 3.00 300% 300.00% 3 3 3.00E+00 300.0E-2
0 0.30 0 0.30 0 0.30 0 0 0.30 0.30 0 0.30 30% 30.00% 2/7 3/10 3.00E-01 300.0E-3
101
The following table shows the built-in date formats for a US English locale and the result after the format is applied to a date.
Format m/d/yy d-mmm-yy d-mmm mmm-yy m/d/yy h:mm 04/18/95 4/18/95 18-Apr-95 18-Apr Apr-95 4/18/95 0:00
The following table shows the built-in time formats for a US English locale and the result after the format is applied to a time.
Format h:mm AM/PM h:mm:ss AM/PM h:mm h:mm:ss m/d/yy h:mm mm:ss [h]:mm:ss mm:ss.0 12:02:02 12:02 PM 12:02:02 PM 12:02 PM 12:02:02 4/18/95 12:02 PM 02:02 12:02:02 02:02.0
102
Use the NumberFormat property. The following code sets NumberFormat to format numbers in the current selection with two decimal places and negative numbers with parentheses.
Dim Fmt As F1CellFormat Set Fmt = F1Book1.CreateNewCellFormat Fmt.NumberFormat = #,##0.00_);(#,##0.00) F1Book1.SetCellFormat Fmt
Use FormatCellsDlg (F1NumberPage) to display the Format Cells dialog box. The Number tab of this dialog box allows you to select existing formats as well as define custom formats. The selected format is applied to all selections. The following code displays the Format Cells dialog box with the Number tab displayed.
F1Book1.FormatCellsDlg (F1NumberPage)
103
The following table lists the format symbols that can be used in a custom format string.
Format Symbol General 0 Description Displays the number in General format. Digit placeholder. If the number contains fewer digits than the format contains placeholders, the number is padded with 0s. If there are more digits to the right of the decimal than there are placeholders, the decimal portion is rounded to the number of places specified by the placeholders. If there are more digits to the left of the decimal than there are placeholders, the extra digits are retained. Digit placeholder. This placeholder functions the same as the 0 placeholder except the number is not padded with 0s if the number contains fewer digits than the format contains placeholders. Digit placeholder. This placeholder functions the same as the 0 placeholder except that spaces are used to pad the digits. Decimal point. Determines how many digits (0s or #s) are displayed on either side of the decimal point. If the format contains only #s left of the decimal point, numbers less than 1 begin with a decimal point. If the format contains 0s left of the decimal point, numbers less than 1 begin with a 0 left of the decimal point. Displays the number as a percentage. The number is multiplied by 100 and the % character is appended. Thousands separator. If the format contains commas separated by #'s or 0's, the number is displayed with commas separating thousands. A comma following a placeholder scales the number by a thousand. For example, the format 0, scales the number by 1000 (e.g., 10,000 would be displayed as 10). Displays the number as scientific notation. If the format contains a scientific notation symbol to the left of a 0 or # placeholder, the number is displayed in scientific notation and an E or an e is added. The number of 0 and # placeholders to the right of the decimal determines the number of digits in the exponent. E- and e- place a minus sign by negative exponents. E+ and e+ place a minus sign by negative exponents and a plus sign by positive exponents. Displays that character. To display a character other than those listed, precede the character with a back slash (\) or enclose the character in double quotation marks (" "). You can also use the slash (/) for fraction formats. Displays the next character. The backslash is not displayed. You can also display a character or string of characters by surrounding the characters with double quotation marks (" "). The backslash is inserted automatically for the following characters: ! ^ & ` (left quote) ' (right quote) ~ { } = < > * (asterisk) Repeats the next character until the width of the column is filled. You cannot have more than one asterisk in each format section.
? . (period)
% , (comma)
E- E+ e- e+
$ - + / ( ) : space
104
hh
mm
105
12-hour time. Displays time using a 12-hour clock. Displays AM, am, A, or a for times between midnight and noon; displays PM, pm, P, or p for times from noon until midnight. Outputs total number of hours. Outputs total number of minutes. Outputs total number of seconds.
s.0, s.00, s.000, ss.0, Outputs fractional part of second. ss.00, ss.000 [Black] [Blue] [Cyan] [Green] [Magenta] [Red] [White] [Yellow] [Colorn] [conditional value] Displays cell text in black. Displays cell text in blue. Displays cell text in cyan. Displays cell text in green. Displays cell text in magenta. Displays cell text in red. Displays cell text in white. Displays cell text in yellow. Displays cell text using the corresponding color in the color palette. n is a color in the color palette. Each format can have as many as four sections: one each for positive numbers, negative numbers, zeros, and text. Using the conditional value brackets ([ ]), you can designate a different condition for each section. For example, you might want positive numbers displayed in black, negative numbers in red, and zeros in blue. The following string formats a number for these conditions:
[>0][Black]General; [<0][Red]General; [Blue]General
The following table shows some examples of custom number formats and numbers displayed using the custom formats.
Format
#.##
#.0#
#,##0"CR";#,##0"DR";0
#,
10000
106
Cell Data 123.45 -123.45 -12.34 1234.567 -12.34 123456789 1234 Anything 123.45 -123.45 text
Display Sales=123.5 -Sales=123.5 x=-12.3 $ 1,234.57 $ -12.34 123-45-6789 Cust. No. 1234 (Not Displayed) The End -The End text 2-3-94 02 03 94 Feb 3, 94 February 3, 1994 3 February 1994 01h 32m 2.56 PM 0315 hours 1 1/4 1 2/8
m-d-yy mm dd yy mmm d, yy mmmm d, yyyy d mmmm yyyy hh"h" mm"m" h.mm AM/PM hhmm "hours" #?/? #?/8
2/3/94 2/3/94 2/3/94 2/3/94 2/3/94 1:32 AM 14:56 3:15 1.25 1.25
Formatting Fonts
You may choose from many different fonts, font sizes, font styles, and font colors for any cells in your workbook. You can set a default font, font size, and style that will apply to all cells in all worksheets in the workbook. Later you can change these settings for individual cells. Changes you make to individual cells will remain, even if you change the default settings. For more information on changing the default font, see Setting the Default Font on page 46. Note By default, Formula One uses Arial as the default font. Be sure you always use a TrueType font as the default font in order for print and display scaling to work correctly.
107
To set font formats for individual cells using the Workbook Designer:
1. Select the cells you wish to format. 2. Choose Format > Cells and click the Font tab, shown below.
A text sample with the font, style, and size you chose appears here. Some fonts provide scripts that allow you to use nonWestern alphabets. Choose the script you want here.
3. Select the font format settings you want, and click OK.
Aligning Data
Formula One allows you to specify how data is aligned within a cell. The standard alignment places text along the left edge of the cell and numbers along the right edge of the cell. Logical and error values are centered.
108
3. Specify the horizontal and vertical alignment of data in the selected cells using the Horizontal and Vertical lists. 4. Select the Wrap Text option to wrap long strings of data to multiple lines within the cell. 5. Click OK.
Use the AlignHorizontal, AlignVertical, and WordWrap properties of the F1CellFormat object to set horizontal and vertical alignment and word wrapping for data in the selected cells. To align the text in the currently selected range(s), you can use the following code:
F1CellFormat.AlignHorizontal = F1HAlignCenter Centers the text horizontally F1CellFormat.AlignVertical = F1VAlignCenter Centers the text vertically F1CellFormat.WordWrap = FALSE Disables word wrapping
Use FormatCellsDlg with the Alignment tab displayed. The following code invokes the Format Cells dialog box with the Alignment tab displayed.
F1Book1.FormatCellsDlg (F1AlignmentPage)
109
Merging Cells
You may merge two or more cells in order to create headings that span many columns or a column entries that span many rows. You can use merged cells to, for example, create a heading for several different columns of data, or to insert a block of text on a worksheet. You may merge cells in the Workbook Designer, or you may use properties and methods. When you merge cells, Formula One removes the cell borders between the merged cells and replaces any data in the cells with the data in the top left cell in the selection. To include all data in the range in the merged cell, copy all the data into the upperleftmost cell within the range before merging. Merged cells function as a single cell on the worksheet, with the row/column reference of the cell in the top-left corner of the range. For example, if you merge cells A1:B5, the resulting cell will have the cell reference A1.
equal to the number of rows and columns in the source range, or a multiple of the number of rows and columns in the source range, or a single cell.
110
For example: A range two rows deep and two columns wide that contains merged cells can be pasted into a range four rows deep and two columns wide, or two rows deep and four columns wide. It cannot, however, be pasted into a range two rows deep and three columns wide.
Allowable ranges to paste merged cells into
111
For Formula One to automatically adjust the height of rows based on the values in cells, select the Auto option button.
2. Select the Custom option button define the default height of rows. 3. Enter a custom setting for the row height in the Custom text box. 4. Select whether the custom row height is entered as inches or centimeters from the Units drop-down list. 5. Click OK.
Select Characters, Centimeters, or Inches for the unit in which the width is entered.
2. Enter a default width for columns and select a unit from the Units drop-down list. 3. Click OK.
112
Click this button to display the Default Row Height dialog box.
3. Select the Custom option button define a custom row height for the selected rows. 4. Enter a custom setting for the row height in the Custom text box. 5. Select whether the custom row height is entered as inches or centimeters from the Units drop-down list. 6. Click OK.
Select Characters, Centimeters, or Inches for the unit in which the width is entered.
2. Enter a custom width for the selected columns and select a unit from the Units drop-down list. 3. Click OK.
113
If multiple rows are selected when you resize a row, all selected rows are resized as you drag a row border. Multiple columns can be resized in the same manner. Double-click the bottom border of a row heading to automatically adjust the height of all cells in the row to accommodate the largest font size in the row. Double-click the right side of a column heading to automatically adjust the width of all cells in the column to accommodate the largest entry. This is shown in the following illustration.
When the pointer appears, double-click this line to automatically size column A. Automatically sizing a column makes the cells wide enough for the longest text in the column.
When the pointer appears, double-click this line to automatically size row 1. Automatically sizing a row makes the cells tall enough for the largest text in the row.
You can also set the size of a selected group of columns or rows to match the size of an existing row or column. First, select the group of rows or columns you want to resize, including the row or column whose size you want to match. Then, click the right border of the column heading or the bottom border of the row whose size you want to match. The selected rows are resized to match the size of the row or column you clicked.
Note You can disable interactive sizing of rows and columns by setting the AllowResize property to False.
ColWidthDlg ColWidthTwips
114
SetRowHeight and SetColWidth set the size of one or more rows or columns. For example, the following code sets the height of rows 1 through 10 to 1/2 inch, and the width of columns 1 through 10 (A through J) to 10 characters wide.
F1Book1.SetRowHeight 1, 10, 720, FALSE F1Book1.SetColWidth 1, 10, 2560, FALSE
SetColWidthAuto and SetRowHeightAuto automatically size rows and columns to accommodate the largest data in the row or column. For example, the following code automatically sets the row and column sizes of rows 1 through 10, and columns 1 through 10 (A through J).
F1Book1.SetRowHeightAuto 1, 1, 10, 10, TRUE F1Book1.SetColWidthAuto 1, 1, 10, 10, TRUE
115
Data contained in frozen panes cannot be edited. You must perform any data editing in these panes prior to freezing. If you attempt to select a cell in a frozen row or column, the entire row or column is selected, just as if you selected a row or column heading. This is shown in the following illustration.
Data in frozen rows and columns cannot be edited. When you attempt to select a cell in a frozen row or column, the entire row or column is selected.
116
To freeze panes using the Format Sheet dialog box in the Workbook Designer:
1. Select Format > Sheet > Properties and select the View tab. 2. Enter a range for the cells that you want to freeze in the Fixed Rows and Fixed Columns text boxes. For example, to freeze columns A - B and rows 1- 4 enter $1:$4 in the Fixed Rows text box and $A:$B in the Fixed Columns text box. 3. Click OK.
Setting the FixedRow and FixedCol properties specify the starting row and column to freeze. The FixedRows and FixedCols properties determine how many rows or columns are frozen from the first row or column. The following example freezes A1:A4.
F1Book1.FixedRow = 1 F1Book1.FixedCol = 1 F1Book1.FixedCols = 1 F1Book1.FixedRows = 4
117
Click a Line Style button to determine a line style for borders. Click a color to determine the color of the borders.
Click the buttons to specify on which sides of the cell or range the borders should appear.
Click directly on any of the areas in this box to toggle the display of borders.
These inside border buttons apply lines to any vertical or horizontal internal borders in the selected range. Inside borders are not available when only a single cell is selected.
Note You must select line style and color before selecting the location of the borders.
3. Select borders using the instructions in the previous illustration. 4. Click OK.
Use the F1CellFormat API object, BorderColor and BorderStyle properties, CreateNewCellFormat method, and the SetCellFormat method to create border styles for a cell or range.
The following example selects a range and places a thick light green border around the range.
Dim cellfrmt As F1CellFormat Set cellfrmt = F1Book6.CreateNewCellFormat thick border around the selection cellfrmt.BorderStyle(F1RightBorder) = F1BorderThick cellfrmt.BorderStyle(F1LeftBorder) = F1BorderThick cellfrmt.BorderStyle(F1TopBorder) = F1BorderThick cellfrmt.BorderStyle(F1BottomBorder) = F1BorderThick green border around the selection
118
Use FormatCellsDlg to invoke the Format Cells dialog box. The following code displays this dialog box with the Border tab displayed:
F1Book1.FormatCellsDlg (F1BorderPage)
To format cells with colors and patterns using the Workbook Designer:
1. Select the cells you want to format. 2. Select Format > Cells and select the Patterns tab from the Format Cells dialog box. The following illustration shows an example of the Patterns tab.
Click Automatic to return to the default fill color and pattern color.
Click None to remove any fill pattern. A sample of the formatting is displayed in this area.
3. Click a fill color in the Fill Color palette to select it. 4. Click a pattern color in the Pattern Color palette to select it. 5. Click a pattern style in the Fill Pattern palette to select it. 6. Click OK.
Use PatternBG, PatternFG, and PatternStyle properties of the F1CellFormat object to choose the background and foreground colors and pattern style for the selected cells.
119
Use FormatCellsDlg to invoke the Format Cells dialog box. The following code displays this dialog box with the Patterns tab displayed:
F1Book1.FormatCellsDlg (F1PatternsPage)
Row headings
Use SetHdrSelection. The following code selects the column heading area.
F1Book1.SetHdrSelection FALSE, FALSE, TRUE
Set the SelHdrRow, SelHdrCol, and SelHdrTopLeft properties to true. The following code selects the top left gray rectangle in the worksheet where the rows and columns intersect.
F1Book1.SelHdrTopLeft = TRUE
120
the font and color of the heading text the pattern and fill color of the heading area the border used to frame heading cells
When the pointer is placed on an edge of the top left corner, it appears as a double arrow.
Click and drag the bottom edge of the top left corner.
Click and drag the right edge of the top left corner.
Use HdrHeight.
Use HdrWidth.
121
2. Enter one or more lines of text to serve as the heading name. 3. Click OK. The heading text is displayed, as shown in the following illustration
When entering text in the Header Name dialog box, you can enter multi-line headings. Press RETURN to enter a line feed and start a new line.
The new text is displayed in the row heading. The row heading area has been resized to display the new heading text.
When you double-click a heading, the Header Name dialog box is displayed. Enter the heading text you want displayed in the dialog box.
You can control interactive editing of headings by setting the AllowEditHeaders property. You can return the value of AllowEditHeaders to determine whether interactively editing headings is allowed.
Use ColText. Use RowText to set or return the text displayed in row headings. TopLeftText sets or returns the text displayed in the top left corner. With ColText and RowText, you must specify the column or row for which you are setting heading text. The following example sets the heading for column 4 to Orders instead of the default C.
F1Book1.ColText (3) = "Orders"
The heading text for column C is replaced with "Orders" by the ColText property.
Note Rows, columns, and cells retain their default numbers and letters in functions, properties, and formulas even if the heading text for rows and columns is changed. For example, the cell at the intersection of column B and row 2 is still referred to as B2 even if the heading text for row 2 has been set to New Sales.
Tidestone
123
C H A P T E R
Formula One provides the ability to create graphical objects in a worksheet. Among the graphical objects you can create are lines, rectangles, ovals, arcs, polygons, buttons, check boxes, dropdown list boxes, and charts. As with other worksheet elements, Formula One provides a wide range of options for formatting and manipulating the appearance of graphical objects you create. For specific information about creating and formatting charts, refer to Working With Chart Objects in this manual. Note Formula Ones graphical objects are incompatible with graphical objects in Microsoft Excel 95 and 97. You may still read and write Excel worksheets, but any graphical objects on those worksheets will not be transferred with the file. If you read or write an Excel file and save the file, any graphical objects that appeared in the original file will be lost.
Graphical objects can be created by calling methods in your code. The Workbook Designer allows graphical objects to be created interactively. You can set the mode of the mouse to allow graphical objects to be created at any time.
The following sections describe each of these methods for creating graphical objects.
Use ObjNew or ObjCreate to create lines, rectangles, ovals, arcs, buttons, check boxes, dropdown list boxes, and charts.
124
The following example creates four adjoining arcs using the ObjCreate method:
Dim pid pid pid pid pid As Long = F1Book1.ObjCreate(F1ObjArc, = F1Book1.ObjCreate(F1ObjArc, = F1Book1.ObjCreate(F1ObjArc, = F1Book1.ObjCreate(F1ObjArc, 0.5, 2.5, 2.5, 4.5, 2, 2, 6, 6, 1.5, 1.5, 3.5, 3.5, 4) 4) 4) 4)
The following example creates four adjoining arcs using the ObjNew method:
Dim objID1 As Long Dim objID2 As Long Dim objID3 As Long Dim objID4 As Long F1Book1.ObjNew F1ObjArc, F1Book1.ObjNew F1ObjArc, F1Book1.ObjNew F1ObjArc, F1Book1.ObjNew F1ObjArc,
.5, 2, 1.5, 4, objID1 2.5, 2, 1.5, 4, objID2 2.5, 6, 3.5, 4, objID3 4.5, 6, 3.5, 4, objID4
Rectangle tool
Oval tool
125
Polygon tool
Draws polygons.
Button tool
Draws buttons.
Dropdown list box tool Draws dropdown list boxes. If Tidestones First Impression charting software is installed on your computer, this button accesses First Impression to create a chart based on the selected range of data.
Chart tool
Interactively drawing graphical objects in the Workbook Designer is as simple as point, click, and drag.
Picture Objects
You can place a picture object on a worksheet and fill it with a metafile. Formula One provides two methods for doing this: one for drawing the picture object, and one for filling it with a metafile.
126
Use ObjNewPicture or ObjCreatePicture to create a picture object on the current worksheet. You must specify the position for the new picture object. When specifying the location of the picture object, integers place the edge of the picture object on a row or column border; fractional numbers place the edge of the picture object between borders.
Use ObjSetPicture to place a metafile in an existing graphical object. You must provide a handle to the metafile and the ID number of the picture object into which you want the metafile placed. Any metafile previously contained by the picture object is freed from memory.
These methods also pass information about the dimensions of the picture and whether the picture can be stretched. Formula One manages the memory associated with a metafile once a picture object has been created, including freeing memory when the graphical object is deleted. You should be familiar with Windows metafiles and their structure before using these methods.
Set the Mode property to change the mouse mode. You can specify that the mouse draw charts, lines, rectangles, ovals, arcs, buttons, polygons, check boxes, and dropdown list boxes. You can also specify that the mouse assume normal worksheet editing mode. Return the value of the Mode property to return the current mouse mode.
The following example uses Mode to set the mouse mode to rectangle drawing when you double-click a worksheet.
Private Sub F1Book1_DblClick(ByVal nRow As Long, ByVal nCol As Long) F1Book1.Mode = F1ModeRectangle End Sub
127
The Name tab displays the identification number for the selected graphical object.
4. Click OK.
If a graphical object is selected, the ObjGetSelection method returns the identification number of the selected object. Formula One maintains a list of graphical objects in each worksheet within a workbook. The order of the graphical objects in that list is determined by the order in which graphical objects are drawn in the worksheet. The farther to the back a graphical object is placed or drawn, the higher the graphical object is placed in the list; the closer to the front a graphical object is placed or drawn, the lower the graphical object is placed in the list. Therefore, when you call ObjFirstID, this method returns the identification number of the first graphical object in the list, which is the graphical object created farthest back in the layers of worksheet graphical objects. Then, ObjNextID returns the identification number of the next closest graphical object, and so on.
Note When you use the ObjBringToFront and ObjSendToBack methods or the Bring To Front and Send To Back commands from the Format menu in the Workbook Designer, you alter the order of the graphical object list maintained by the worksheet.
s
If an graphical object has been named, you can return the identification number of the named graphical object with the ObjNameToID method.
128
Set the ObjName property to name a graphical object. Once a graphical object is named, return the value of ObjName to obtain the name assigned to a graphical object. You can also call FormatObjectDlg (F1NamePage) to display the Format Object dialog box with the Name tab displayed.
Note After a graphical object is named, you must press CTRL to select it at runtime. In addition, if the ObjClick or ObjDblClick events are enabled, you must press CTRL when clicking the graphical object.
129
ObjSetSelection selects the graphical object you specify by graphical object identification number. This method unselects any previously selected graphical objects or worksheet ranges. ObjGetSelection returns the identification number of the selected object. If more than one object is selected, you must indicate for which object to return an identification number. ObjAddSelection selects the specified graphical object; all previously selected objects remain selected.
130
ObjSelection returns the identification number of the selected graphical object. If more than one graphical object is selected, you must indicate for which graphical object to return an identification number. ObjGetSelectionCount returns the number of graphical objects currently selected.
131
F1Book1.ObjGetPos 1, x1, y1, x2, y2 F1Book1.ObjSetPos 1, x1, y1, (x2 - 1.5), (y2 - 5)
132
Only the second anchor point is repositioned. Thus, the oval is resized.
You can also use the ObjPosShown method to return the graphical objects display status.
Call the methods ObjBringToFront or ObjSendToBack to arrange graphical objects. These methods move only the selected graphical objects.
133
If multiple graphical objects are selected when using these commands and methods, the order of graphical objects within the selection remains unchanged. The selected graphical objects are placed in front of or behind only the unselected graphical objects.
fill patterns and colors; line colors; and widths and styles for arcs, lines, ovals, polygons, and rectangles the lists of items contained by dropdown list boxes the text displayed by check boxes or buttons
To set fill colors and patterns for selected graphical objects in the Workbook
Designer: 1. Select the graphical object. 2. Select Format > Object to display the Format Object dialog box. 3. Select the Patterns tab. 4. Click a fill color in the Fill Color palette. This assigns a background color to the graphical object. 5. If you want to assign a pattern to the object, click a pattern style in the Fill Pattern palette, then click a pattern color in the Pattern Color palette. The pattern color will be the foreground color in the pattern. 6. Click OK.
To set fill colors and patterns for selected graphical object programmatically:
s
Use SetPattern to set the fill colors and pattern for the selected objects. Use ObjPatternStyle, ObjPatternBG, and ObjPatternFG to set the fill colors and pattern for the selected graphical objects.
134
Call the FormatObjectDlg (F1PatternsPage) to display the Format Object dialog box with the Patterns tab displayed.
5. Click a line weight. Solid lines can be 1/2 point, 1 point, 2 points, or 3 points in weight. Styled lines can be 1/2 point in weight. The line weights are shown in the following illustration:
1/2 point (displayed as 1 point rule on low resolution monitors). 1 point 2 points 3 points
6. Click a color in the Color palette. This assigns a color to the line. 7. Click OK.
135
Use SetLineStyle to set the line style, color, and weight for the selected objects. Use the LineStyle, LineColor, and LineWeight properties to set the line style, color, and weight for the selected graphical objects. Call FormatObjectDlg (F1LineStylePage) to display the Format Object dialog box with the Line Style tab displayed.
If you want the results of a selection to be displayed in a cell, type the cell location in the Cell text box.
Enter or edit the list of items contained by the dropdown list box. The items must be entered as a semicolon-delimited list.
Check the Assign As Text check box to assign the dropdown list box items as text, rather than values.
136
Set ObjItems to specify a list of items for a dropdown list box. For this property, you provide a semicolon-delimited list of items. The list you provide replaces any previously specified lists. Return the value of ObjItems to get a semicolondelimited list of items from a list box. To change an item in a list of items, set ObjItem. For this property, you provide the number of the item you want to change and the new value for the item. Return the value of ObjItem to get a specific item from a dropdown list box. To add an item to a list of items, use ObjAddItem. This method adds an item to the end of the current list. Use ObjInsertItem to add an item at a specific location within a list. Use ObjDeleteItem to delete an item from a dropdown list box. ObjGetItemCount returns the number of items contained by a dropdown list box. Use FormatObjectDlg (F1OptionsPage) to display the Format Object dialog box with the Options tab displayed.
137
Set the ObjText property. Return the value of ObjText to get the text displayed by a check box.
Formatting Buttons
The text displayed on a button can be set either through the Workbook Designer or programmatically.
Set the ObjText property. Return the value of ObjText to get the text displayed on a button.
At runtime, items can be checked or selected interactively using the mouse. Properties and methods can set the value of a check box or dropdown list box object. By assigning a cell to a graphical object, you can set the value in the cell by making a selection from the graphical object. Likewise, if you enter a value that is in the list associated with a dropdown list box, you can change the value displayed in the dropdown list box. The cell reflects the value to which the graphical object is set, regardless of the method used to set the value. When you check or uncheck a check box, or select an item from a dropdown list box, you set the value in the assigned cell.
For a check box, the value of the assigned cell is True if the graphical object is checked or False if unchecked. In a dropdown list box, you can choose to have the value of the assigned cell set to the number or the text of the selected item. Items in a dropdown list box are numbered starting with 0 (e.g., the first item is item 0, the second item is item 1, and so on). -1 means that no item is selected in the dropdown list box.
138
To set the value of a check box, position the pointer anywhere in the check box area and click. The check box toggles between checked and unchecked states. To set the value of a dropdown list box, position the pointer anywhere in the dropdown list box area and click. The list of items contained by the dropdown list box is displayed. If the list area is not large enough to display all the items, you may have to click the scroll areas to view the entire list. Then, click the item you want to select.
For check boxes, provide 1 to check a check box; provide 0 to uncheck the graphical object. For dropdown list boxes, provide the number of the item you want to select. Dropdown list box items are numbered consecutively, starting with 0. If you specify -1, no item is selected in the dropdown list box. Return the value of ObjValue to get the value of the current selection.
For dropdown list boxes, you can also use ObjText to set or return the text displayed on a button or next to a check box.
If you select an item from the graphical object, the value or text of that selection is displayed in the referenced cell. For example, if you uncheck a check box, FALSE is placed in the cell the check box references. If you enter a valid value in the referenced cell, the current selection of the graphical object reflects the cell value. For example, if you enter 0 in the cell, a dropdown list box that references the cell displays its first item as the current selection.
If multiple graphical objects reference the same cell, making a selection in one graphical object makes the same selection in all graphical objects that reference the cell. The cell reference for a graphical object can be set in the Options tab of the Format Object dialog box.
139
Editing Polygons
When editing polygons, there are two editing modes:
s
Normal Polygon Editing. This mode allows you to resize and move polygons. Editing of polygon points is not allowed in this mode. Polygon Point Editing. This mode allows you to reposition polygon points, thus changing the shape of the polygon.
You can set the polygon editing mode by setting the PolyEditMode property. To determine the current polygon editing mode, return the value of PolyEditMode. In the Workbook Designer, to use normal polygon editing click the polygon and move the selection handles appropriately. If you want to use polygon point editing, click the polygon point editing tool and move the selection handles of the polygon. The following illustration shows a selected polygon when normal polygon editing and polygon point editing modes are enabled.
When normal polygon editing mode is enabled, the selection handles appear at the edges of the bounding box that surrounds the polygon. In this mode, the polygon can be resized and moved.
When polygon point editing mode is enabled, a selection handle appears at each point along the border of the polygon. In this mode, the polygon points can be repositioned and the polygon can be moved.
140
141
C H A P T E R
If you have also purchased Tidestones First Impression ActiveX control, you can automatically chart worksheet data. In order to draw a chart, First Impression must be properly installed on your system. The following illustration shows an example of a chart on a worksheet.
Creating Charts
To create a chart programmatically:
s
Use the ObjCreate with the F1ObjChart constant or the ObjNew method. These methods draw a chart object on the worksheet in the position you specify and chart the currently selected range. To change a charts data range, you must select it, open the Format Object dialog box, select the Options tab, and provide a range reference or defined name for the chart.
142
3. Using the chart tool, draw a rectangle where you want to place the chart. The Chart Wizard appears to assist you in designing the chart appearance. 4. Make any necessary selections from the Chart Wizard and click Finish.
143
2D Charts
3D Charts
Series Labels
Bar Gap
Series Stacking
144
Important When you use the Chart Wizard to modify existing charts, the Wizard reverts the chart to its default settings and then restores only those features it controls in the Gallery, Layout, and Axes tabs. Exercise care when modifying charts that may have originally been created without the Wizard. You may need to manually adjust some chart settings after using the Wizard.
145
The Chart Wizard provides a quick and easy method for applying some of the most common formatting options to your chart. Additional formatting options are available by using the First Impression Chart Designer. The Chart Designer is displayed by double-clicking on chart elements in an activated chart object, or selecting Chart Designer from the First Impression context menu. You can modify chart data by selecting Edit Chart Data from the First Impression context menu. The Data Grid Editor will appear. Consult your First Impression documentation for more information about the Chart Designer, the Data Grid Editor, and other First Impression functions.
Important One of the options on the First Impression context menu is Edit Chart Data. This displays First Impressions Data Grid Editor. Using this tool you can modify the size and content of the charts data source. Any changes you make in the Data Grid Editor are reflected in the chart, but are NOT reflected in the worksheet. Also, if you use the Data Grid Editor to edit the chart data and then recalculate the workbook in Formula One while the chart still references a range in
146
the worksheet, the worksheet data overwrites your changes. To prevent this, select the chart, choose Format > Object, and replace the charts formula with an empty string (" ") before using the Data Grid Editor to edit the data.
Chart Options
Within Formula One, you can control whether or not users can edit the chart and change the source data range for a chart using the Options tab of the Format Object dialog box.
Unselect this option to prevent users from formatting the chart. Formula identifying the source data range for the chart.
Developers Note If you make the Workbook Designer available to your end users, they will have access to the Allow User Changes check box. To prevent them from modifying a chart regardless of this setting, set the AllowObjSelections property to False.
147
This worksheet provides summary information about the inventory data stored on the worksheets named Region 1 and Region 2. These cells contain formulas that sum information from the worksheets individual region.
Tidestone
149
C H A P T E R
1 0
Printing Worksheets
Formula One provides many options for printing worksheets and setting printing specifications.
s
You can print worksheets through the Workbook Designer. You can use properties and methods of the F1PageSetup object to print worksheets directly. See the Formula One online documentation for more information on the F1PageSetup object and its properties. You can also use methods to display the Page Setup and Printer Setup dialog boxes.
Printing Worksheets
You can print the active worksheet from the Workbook Designer, or from code.
Use the FilePrint method. The following code uses this method to print a worksheet.
F1Book1.FilePrint TRUE
When you call FilePrint, the Print dialog box can be displayed, allowing you to specify the pages to print, the number of copies to print, and other related items.
s
Use FilePageSetupDlgEx to display the Page Setup dialog box, which gives easy access to setting margins, headers, footers, headings, grid printing, page ordering, and output alignment. The following code displays the Page Setup dialog box.
F1Book1.FilePageSetupDlgEx
150
Use the FilePrintEx method. The following code uses this method to print selected worksheets or the entire workbook as a single document.
F1Book1.FilePrintEx bShowPrintDlg, bPrintWorkbook
When you call FilePrintEx, the Print dialog box can be displayed, allowing you to specify the pages to print, the number of copies to print, and other related items.
The Print dialog default printing selection can be changed by setting the appropriate flag in the FilePrintEx method.
Use FilePrintSetupDlg to invoke the Print Setup dialog box; the standard Windows printer setup dialog box is displayed. It allows you to select a printer, select the paper source, and select the page orientation (portrait or landscape). The following code displays the Print Setup dialog box.
F1Book1.FilePrintSetupDlg
To set the print area with menu commands in the Workbook Designer:
1. Select the ranges to print. 2. Select File > Print Area > Set Print Area.
151
To set the print area using the Page Setup dialog box in the Workbook Designer:
1. Select File > Page Setup and click the Sheet tab. The Sheet tab of the Page Setup dialog box will appear, as shown below.
If a print area was already set, the range(s) will appear here.
2. In the Print Area text box, enter the range(s) on the selected worksheet(s) that you want to print. You may enter absolute or relative cell references. Separate noncontiguous ranges with commas. When you finish, click OK.
The following example uses the PrintArea property to set A1:D25 as the area to be printed.
Dim pgSetup As F1PageSetup Set pgSetup = F1Book1.CreateNewPageSetup pgSetup.PrintArea = "A1:D25" F1Book1.SetPageSetup pgSetup
You can select multiple ranges to print. The ranges do not have to be adjacent. For example, a print area could be comprised of two ranges, A1:D4 and F5:I8.
152
To set the print titles with menu commands in the Workbook Designer:
1. Select the rows or columns to use as print titles. You must select entire rows or columns. 2. Select File > Print Titles > Set Print Titles.
To set the print titles using the Page Setup dialog box in the Workbook
Designer: 1. Select File > Page Setup and click the Sheet tab. The Sheet tab of the Page Setup dialog box will appear, as shown on page 151. 2. In the Print Titles text box, enter the row and/or column range(s) on the selected worksheet(s) that you want to appear on every page of the printout. You may enter absolute or relative cell references. Separate non-contiguous ranges with commas. When you finish, click OK.
The following example uses the PrintTitles property to set rows 1 and 2 and column A as print titles.
Dim pgSetup As F1PageSetup Set pgSetup = F1Book1.CreateNewPageSetup pgSetup.PrintTitles = "A1:IV2,A1:A65536" F1Book1.SetPageSetup pgSetup
For horizontal (row) page breaks, the page break will be placed above the active or specified cell. For vertical (column) page breaks, the page break will be placed to the left of the active or specified cell.
153
AddRowPageBreak, AddColPageBreak, RemoveRowPageBreak, and RemoveColPageBreak add and remove page breaks adjacent to the row or column that you specify in the method. The following example uses the AddRowPageBreak method:
Dim theRow As Long theRow = 8 F1Book1.AddRowPageBreak theRow
NextRowPageBreak returns the next page break below the row that you specify in the method. NextColPageBreak returns the next page break to the right of the column that you specify in the method. The following example uses the NextRowPageBreak method:
Dim nextBreak As Long Dim theRow As Long theRow = 20 nextBreak = F1Book1.NextRowPageBreak (therow)
154
Specifying Margins
You may set margins in inches or centimeters, or you may tell Formula One to use whatever margins it takes to print the print area in the center of the worksheet. You may also establish margins for headers and footers.
Click here to center the page between the left and right margins. Click here to center the page between the top and bottom margins.
Use these boxes to enter the distance between the edge of the page and the header or footer. If the header or footer margin is larger than the top or bottom margin, the header or footer will overwrite the worksheet data on the page.
2. Select the options you want. Click OK when you are done.
Use the following properties of the F1PageSetup object: TopMargin, LeftMargin, BottomMargin, RightMargin, HeaderMargin, FooterMargin, CenterHoriz, and CenterVert.
155
To scale the worksheet in order to make it fit on a certain number of pages, click the Fit to button, then enter the number of pages tall and wide in these dialog boxes.
If you dont want page numbering to start at 1, enter the first page number here.
Choose Automatic to start numbering pages at 1 (if this is the first or only worksheet in the print job) or at the next sequential number (if this is not the first worksheet in the print job).
2. Select the options you want. Click OK when you are done.
156
2. Type text and special formatting codes in the Header and Footer boxes. See below for information on special formatting codes. When you finish, click OK.
157
Use the Landscape property of the F1PageSetup object. If you do not set this property, landscape printing can be handled using your systems default Print dialog box.
158
3. To force the chart to fit on a specified number of pages, click the Fit to button, then enter the number of pages tall and pages wide you want the worksheet to fit into. 4. When you finish choosing options, click OK.
Use the PrintScale, FitPages, PagesWide, and PagesTall properties of the F1PageSetup object.
159
If your printout has multiple pages, you can use the Next Page and Prev Page buttons to view the different pages.
160
An image of what the printout will look like appears on the screen, showing the margins, headers and footers, print titles, page breaks, and other printing features discussed in this chapter. When you finish, click Close. To print the worksheet(s) directly from this screen, click Print. Formula One prints all pages as shown, without showing you the Print dialog box, and closes Print Preview.
161
C H A P T E R
1 1
Database connectivity is one of Formula Ones most powerful features. You can use Formula One, along with ODBC drivers, to retrieve data from a database and use it to populate a Formula One worksheet at the starting row and column position you specify. This ODBC connection offers incredible speed and flexibility in populating your worksheet.
162
a connect object (F1ODBCConnect). a boolean that controls whether SQL errors are displayed. The following code example shows the use of this object and method:
If Command1 = True Then Dim pConnect As New F1ODBCConnect Dim F1obdcconnect As String pConnect.ConnectStr = F1ODBCConnect F1Book1.ODBCConnectEx pConnect, True connecterror: MsgBox Error
To allow the user to select the database at runtime, the F1ODBCConnect object should be equal to a null string.
163
If you are using the ODBCConnect method to connect the active worksheet to a data source, you provide ODBC connection with the following:
s
a variable containing a connect string. a boolean that controls whether SQL errors are displayed. a variable that receives the returned SQL status code. The following code example shows the use of this method:
On Error GoTo ConnectError Dim returnCode As Integer, pConnect As String F1Book1.ODBCConnect pConnect, True, returnCode Exit Sub ConnectError: MsgBox Error
The connect string must be a variable. This allows you to let the user select the database at runtime and returns the data source in the connect string. Next, a dialog box is displayed, allowing the user to select or create a file data source or machine data source at runtime. The following illustration shows the File Data Source tab of the Select Data Source dialog box
This selection describes the driver for which you want to connect. You can use any file data source that refers to an ODBC driver on your machine.
If you want to create a new data source, click New. This launches the ODBC Datasource Administrator Utility for your database. For more information, consult your database administrator documentation. For more information about ODBCConnect or ODBCConnectEx, refer to the Formula One online documentation.
164
an ODBC query object. if the query string is null, the ODBC Query dialog box is displayed to allow the user to build the query at runtime. row and column coordinates that identify where in the active worksheet the returned data is to be placed. a boolean that determines whether the ODBC Query dialog box is displayed. variables that control whether data and data type information is used to format the worksheet size, column headings, column width, and cell formatting. a variable that received the returned status code.
165
If you are using ODBCQuery, you must provide the following information:
s
a variable that specifies the query syntax. If you pass a null string for this argument, the ODBCQuery dialog box is displayed to allow the user to build the query at runtime. The query string must be passed as a variable. This allows you to let the user build the query at runtime and returns the final query string. row and column coordinates that identify where in the active worksheet the returned data is to be placed. a boolean that determines whether the ODBCQuery dialog box is displayed. variables that control whether data and data type information is used to format the worksheet size, column headings, column width, and cell formatting. a variable that received the returned status code.
166
If the query string is null or you set the bShowDialog value to True, the query dialog is displayed as shown in the following illustration.
Connection Information
Use these Table and Fields lists to assist you in building your query.
Type the SQL syntax for your query in this text box.
Set Column Widths. Check this box to automatically set the width of each column to be wide enough to display the widest data in the column. Set Column Names. Check this box to display field names instead of the standard alphabetic column headings. Even though field names are displayed as the column headings, formulas must still use the standard cell referencing conventions (e.g., A1). Set Column Formats. Check this box to have formats for date, time, and currency fields set automatically when data is placed in the worksheet. If you do not check this box, you must set the formats for these columns manually. Set MaxRow & MaxCol. Check this box to have the maximum number of worksheet rows and columns set to the number of records and fields returned by the query.
167
When you click OK in the ODBC Query dialog box, the query is executed. The following example shows the results of a returned query.
Notice that Set Column Names and Set MaxRow and Max Column have been set to True. Column labels have been replaced with database field names and the size of the worksheet has been adjusted to the number of returned columns and rows.
Note To maintain Excel compatibility, each cell is limited to 256 characters. If the returned data exceeds this limit, the text is truncated to fit in the cell
Establish a database connection using ODBCConnectEx or ODBCConnect. Build a PREPARE statement using ODBCPrepareEx or ODBCPrepare. If necessary, bind the PREPARE statement parameters to worksheet columns using one or more ODBCBindParameterEx or ODBCBindParameter methods. Execute the PREPARE statement with ODBCExecuteEx or ODBCExecute.
In addition, Formula One provides tools for handling errors that occur during this process:
s
ODBCError. ODBCError can be checked after failure of any Formula One ODBC method. ODBCErrorMsg. The ODBCErrorMsg property returns a detailed message of the error that occurred. ODBCNativeError. The ODBCNativeError property displays ODBC native error information to the user following an ODBC method failure.
168
ODBCExecuteError. The ODBCExecuteError event allows you to determine what happens if an error is encountered during the execution of the prepared statement. ODBCSQLState. The ODBCSQLState property shows an SQL state error number after failure of any Formula One ODBC method.
A common way you might want to incorporate these features into a Formula One application is to populate a worksheet with database data using ODBCQueryEx or ODBCQuery which allows the user to edit the information, and then update the database with the user updates. You can use the EndEdit event to determine if the user has made changes, or the SelChanged event to determine when a user leaves a particular row.
The following code for ODBCPrepare adds a new record to the Product table.
F1Book1.ODBCPrepare "INSERT INTO Product (id,name,description,size,color,quantity,unit_price)", "VALUES (701,Sunglasses,wrap-around,Medium,Black,80,75)", retCode
However, when working with worksheets, you more commonly want to supply data from the worksheet as a parameter in your PREPARE statement. For example, if you have a number of new authors listed in a worksheet and you want to add them all to your database you could use variable parameters to make your PREPARE statement more dynamic. In this way you can supply data from the worksheet as the statement is executed.
169
The following code for ODBCPrepareEx allows the user to supply data to the worksheet as the statement is executed:
retcode = F1Book1.ODBCPrepareEx ("INSERT INTO Product SET (id = ?, name = ?, description = ?, size = ?, color = ?, quantity = ?, unit_price = ?)")
The following code for ODBCPrepare allows the user to supply data to the worksheet as the statement is executed:
F1Book1.ODBCPrepare "INSERT INTO Product SET id = ?, name = ?, description = ?, size = ?, color = ?, quantity = ?, unit_price = ?", retCode
In this case, each of the question marks is a variable parameter tag that must be bound to a worksheet column using the ODBCBindParameterEx.
The following examples binds these columns. F1Book1.ODBCPrepare "INSERT INTO Product SET id = ?, name = ?, description = ?, size = ?, color = ?, quantity = ?, unit_price = ?", retCode
Binds the first question mark to the second worksheet column and specifies that the data type as Long.
F1Book1.ODBCBindParameter 1, 2, F1CDataLong, retcode
170
Binds the second question mark to the second worksheet column and specifies the data type as Character.
F1Book1.ODBCBindParameter 2, 2, F1CDataChar, retcode
If you do not provide a bind for each question mark in the PREPARE statement, the ODBCExecute or ODBCExecuteEx statements fail. Formula One does no checking to verify that the data in the column matches the type you have specified. If there is a data conversion error during an ODBCExecuteEx or an ODBCExecute, the ODBCExecuteError event is fired. ODBCExecuteError allows you to trap for data conversion errors and determine a course of action. The error handler also returns the affected row and column in the worksheet so that you can determine which cell is causing the problem.
If an error occurs during an ODBCExecuteEx or ODBCExecute, an ODBCError, ODBCSQLState, ODBCNativeError, or ODBCErrorMsg is executed. You can provide code to determine what happens when an error is encountered.
171
C H A P T E R
1 2
Using Formula One, you can save an entire worksheet in HTML format for use on the Internet, or embed a Formula One worksheet in an existing HTML file. You can write only the HTML data or pass the full design capabilities of the Workbook Designer to your HTML document. Formula One can also be used by containers for Internet and corporate Intranet application development. The Formula One 5.0 ActiveX workbook control has been digitally signed by Verisign Commercial Software Publishers CA and supports the to IObjectSafety interface for secure data. There are a number of tools available to assist you in creating the necessary files for displaying the Formula One ActiveX workbook control on your web page. For an up-to-date list of tools and instructions on how to obtain them, visit our website at http://www.tidestone.com/internet.
HTML. HTML format including data formatting, font and color information. HTML (Data Only). HTML format includes data formats, but excludes font and color information.
Use the SaveFileDlg or SaveFileDlgEx method to call the Write dialog box. The following example uses SaveFileDlgEx to call the Write dialog box. The default file type is set to HTML.
Dim pFileInfo As New F1FileSpec pFileInfo.Name = F1Book1.Title pFileInfo.Type = F1FileHTML F1Book1.SaveFileDlgEx "Save As HTML", pFileInfo
172
173
174
175
The following worksheet functions are also disabled in your browser when the safe request is detected:
CALL REGISTER.ID
Note If you want to load a workbook from an Internet address, use the URL property. For additional information about this property, refer to the Formula One Online Documentation.
Tidestone
177
C H A P T E R
1 3
Avoid formatting blank cells. It is more efficient to format an entire row or column because no cells are created. When you format a blank range that does not consist of whole rows or whole columns, Formula One must create empty cells before it can apply the format. To find and eliminate blank formatted cells in your worksheet, show cell markers by using the ShowTypeMarkers property. (You can do this in the Workbook Designer by choosing Tools > Options, clicking the General tab, and checking the Show Markers box.) With markers turned on, Formula One will display a blue frame inside blank, formatted cells. Build worksheets by rows instead of columns. Formula One allocates memory by rows. You can save memory by building tables a row at a time, rather than a column at a time. For example, fill cells in row 1 before moving to row 2, and so on, rather than filling cells in column A before moving to column B, and so on. Build ranges from the lower right corner. When building a table one cell at a time from code, it is faster and more efficient to start in the lower right corner of the area in which you are working. This ensures that the row pointers are allocated simultaneously instead of one at a time. Likewise, each row is allocated once instead of being reallocated as each cell is added. Use values instead of formulas whenever possible. Avoid adding empty rows and columns for white space. Adjust the row height or column width to create white space instead of adding empty rows or columns. If you must have additional white space on your worksheet, empty rows are more efficient than empty columns. Disable repainting when performing a series of operations. When performing a number of sequential operations on a worksheet, disable repainting with the Repaint property so the screen does not repaint after each operation. This increases the speed of the operation and avoids unnecessary screen flashing.
178
Use methods to copy and move data. Use EditCopyRight, EditCopyDown, CopyRange, CopyRangeEx, and MoveRange to copy and move cells. These methods are much faster than using the clipboard. In addition, these methods update cell references to maintain the integrity of your formulas.
179
Finally, there are the cells themselves, which are small data structures containing the cells contents. The structures include a cells value, its format, its formula, its font, its alignment, and other cell attributes. Cells only exist in memory if they contain formulas or data or are formatted differently from the row or column in which they are located.
180
When you expand the row pointer array or a cell pointer array, Formula One must ask for a larger piece of memory, copy the contents of the current array into the new memory array, and then return the previous memory block to the memory pool. The 9,999 memory operations you eliminated are the most expensive operations. How can this be? The secret is that the optimized method for filling the worksheet avoided dealing with fragmented memory, as happened with the slow method. As the cell pointer arrays grew larger, the remaining chunks of free memory were not big enough for the growing arrays. This caused Windows to start paging memory to disk to produce large enough memory chunks. You can achieve the same results without actually filling a worksheet from bottom to top. When you start filling data, make sure the maximum-needed row pointer array is allocated by entering a cell in the last row you are going to use. This forces a row pointer array to be created that will accommodate your entire worksheet. Then, it doesnt matter what row you fill next because this array will not change. Likewise, if you always create the last cell in any row first, the maximum-needed cell pointer array is created. Then, you can enter the cells in that row in any order without affecting performance.
181
Limited by system resources (windows and memory) Excel 5.0, 95, and 97
Tidestone
183
C H A P T E R
1 4
This chapter provides information about add-in functionssmall programs that extend the capabilities of Formula One. The examples presented here demonstrate how to extend Formula Ones functions by adding the capability to use array arguments in functions using Visual Basic and C++.
184
As Formula Ones add-in capabilities increase, future versions may look for new classes in addition to F1Functions. To maximize compatibility with future versions of Formula One, add-in developers should refrain from using the prefix F1 on internal class names in their add-in DLLsespecially on classes that are creatable. Formula One presents the ActiveX DLLs project description to end-users via the Add-In Manager dialog; therefore, the project description should be an informative phrase (typically no longer than a short sentence) describing the addin DLL. The Project Description field can be found on Visual Basics Project Properties dialog under the General page.
Thread Safety
Although Formula One is single-threaded, future versions of Formula One may support multithreading. If so, Formula Ones calc engine will create a separate instance of F1Functions for each thread. This means that if your add-in functions use only automatic variables or data defined within the F1Functions class, you will not need to be concerned about thread safety. However, if you must refer to data outside of F1Functions (for example, if all threads must share common data), you are responsible for ensuring that your code is thread-safe.
185
*Use Variant when a single function can accept or return values of different types. A Variant may also be of type vbEmpty. A Variant argument cannot accept a reference to more than one cell. If you need to accept such references, you may use F1AddInArray or F1AddInArrayEx instead.
F1AddInArray
Use the type F1AddInArray when using an area reference as an argument. You must add the Formula One control to your project to use this type. F1AddInArray will only accept a simple referencea reference to a single 2d area. If you specify a 3d area or union reference, the formula evaluator returns #VALUE! without calling the add-in function. Use F1AddInArrayEx for support of 3d area or union references. The members of F1AddInArray are:
Function Rows() As Long Function Cols() As Long Function GetArrayType() As Long Function GetValue(ByVal Row As Long, ByVal Col As Long) Function IterStart() As Boolean Function IterNext() As Boolean Function IterGetValue() As Variant Function IterGetValueEx(Row As Long, Col As Long) As Variant
F1AddInArray.GetArrayType always returns F1AddIn2dArea. You may use IterStart and IterNext in a loop to iterate through the non-empty elements of the array. This can be much faster than examining each element individually when a sparsely populated array is expected.
Example Code
Dim Found As Boolean Found = TheArray.IterStart() While Found Use IterGetValue or IterGetValueEx to retrieve the value of the current element. Found = TheArray.IterNext() Wend
186
F1AddInArrayEx
You may also use the type F1AddInArrayEx when using an area reference as an argument. Like F1AddInArray, F1AddInArrayEx accepts simple 2d area references. However, F1AddInArrayEx also accepts 3d area and union references. To only allow 2d area references, use F1AddInArray. You must add the Formula One control to your project to use this type. The members of F1AddInArrayEx are:
Function Areas() As Long Number of Areas in Array Function Rows(ByVal Area As Long) As Long Nbr Rows in Area Function Cols(ByVal Area As Long) As Long Nbr Cols in Area Function GetArrayType() As Long Function GetValue(ByVal Area As Long, ByVal Row As Long, _ ByVal Col As Long) Function IterStart() As Boolean Function IterNext() As Boolean Function IterGetValue() As Variant Function IterGetValueEx(Area As Long, Row As Long, Col As Long) _ As Variant
F1AddInArrayEx.GetArrayType returns F1AddIn2dArea, F1AddIn3dArea or F1AddInRegion. Note You may use IterStart and IterNext in a loop to iterate through the nonempty elements of the array. This can be much faster than examining each element individually when a sparsely populated array is expected.
187
Example 2
=CONCATENATETHESE("ABC","XYZ") All arguments must be ByVal Function ConcatenateThese(ByVal X As String, _ ByVal Y As String) As String ConcatenateThese = X + Y End Function
Example 3
=SUMOFRANGE(A1:C5) All arguments must be ByVal Function SumOfRange(ByVal Range As F1AddInArrayEx) _ As Double On Error GoTo ErrorHandler Dim Sum As Double Sum = 0 Dim GotOne As Boolean GotOne = Range.IterStart While GotOne Sum = Sum + CDbl(Range.IterGetValue) GotOne = Range.IterNext Wend SumOfRange = Sum Exit Function ErrorHandler: Err.Raise F1AddInValueError End Function
Example 4
=MAKEERROR(TRUNC(RAND()*7)+1) All arguments must be ByVal Function MakeError(ByVal WhichOne As Double) _ As Double Select Case WhichOne Case 1 Err.Raise F1AddInNullError #NULL! Case 2 Err.Raise F1AddInDivZeroError #DIV/0!
188
189
Where:
pResult
is a pointer to the variant that holds the add-in functions result. is reserved for future use. The add-in function should ignore this
nReserved
argument.
nArgs pArgs
is a pointer to an array of nArgs variants, which are the arguments being passed to the add-in function. The first argument is at index 0, the second is at index 1, etc. If nArgs is 0, then this pointer is invalid.
Note Formula Ones formula evaluator always clears the variants pointed to by pResult and pArgs. The add-in function should not clear these. Return Value The only valid return values for an add-in function are S_OK and E_OUTOFMEMORY. To report a formula evaluation error, set pResults type to VT_ERROR and its value to one of the error codes listed in Formula Evaluation Errors on page 198, and return S_OK.
190
F1AddinInit
The add-in DLL must export the F1AddInInit function, which is declared as follows:
extern "C" { HRESULT __declspec(dllexport) __stdcall F1AddInInit( F1AddInRegisterInfoProc RegisterInfoProc, F1AddInRegisterFunctionProc RegisterFunctionProc, int nReserved1, int nReserved2); };
Where:
RegisterInfoProc
points to a callback function implemented by Formula One. F1AddInInit calls this function to provide global information about the add-in DLL such as its name and a short description.
RegisterFunctionProc
also points to a callback function implemented by Formula One. F1AddInInit provides information about the DLLs add-in functions to Formula One by calling this function once for each add-in function that the DLL implements. and nReserved2 are reserved for future use. The add-in should ignore these arguments.
nReserved1
F1AddInRegisterInfoProc
This function is called from the add-ins F1AddinInit code to register information about the add-in. A pointer to this callback is paired to the add-in through the F1AddinInit functions.
HRESULT CALLBACK F1AddInRegisterInfoProc( LPWSTR pwszName, LPWSTR pwszDescription, int nReserved1, int nReserved2);
Where:
pwszName
is a Unicode string specifying the name of the add-in DLL. This should be a short name of (typically) one or two words.
191
is a Unicode string describing the add-in DLL. This should be a short descriptive phrase, no longer than a single sentence. and nReserved2 must be zero so that the add-in ignores these arguments.
nReserved1
F1AddInRegisterFunctionProc
Each function in the add-in must be registered by calling the F1AddInRegisterFunctionProc function which is paired to the F1AddinInit entry point.
HRESULT CALLBACK F1AddInRegisterFunctionProc( LPWSTR pwszName, int nReserved, F1AddInFunction pFunction, int nArgs);
Where:
pwszName
is a Unicode string specifying the name of the add-in function. It is not case sensitive. must be zero.
nReserved pFunction
nArgs
is the number of arguments expected by the function. If the add-in function can accept a variable number of arguments, this should be 1; otherwise, Formula One will not attempt to call the function with any number of arguments other than nArgs.
Formula One accepts any of the above value types as an add-in functions result except VT_UNKNOWN.
192
When an add-in function encounters an argument of type VT_UNKNOWN, it should use QueryInterface to obtain an interface it can use to retrieve the data. At this time, the only interfaces implemented for this purpose are IF1AddInArray and IF1AddInArrayEx.
s
Query for IF1AddInArray on an argument where you only want to accept two-dimensional area references. Query for IF1AddInArrayEx on an argument where you want to accept threedimensional area references. This interface also provides all the functionality of IF1AddInArray.
If the add-in function fails to obtain a suitable interface through QueryInterface, it should return the formula evaluation error code F1_E_VALUE. See General Design Principles on page 183, for information on returning formula evaluation errors.
IF1AddInArray interface
When an argument to an add-in function is a two-dimensional area reference, Formula One passes that reference to the add-in function as an IF1AddInArray interface. (The IF1AddInArrayEx interface is also implemented; the add-in function may use whichever interface best suits its needs.) IF1AddInArray, not technically an array, provides a mapping mechanism for exposing a range in the workbook. In future versions of Formula One, the same interface may expose true arrays to the add-in function. This section describes the members of IF1AddInArray.
IF1AddInArray::Rows
Returns the number of rows in the array.
int Rows(void);
IF1AddInArray::Cols
Returns the number of columns in the array.
int Cols(void);
IF1AddInArray::GetArrayType
Returns the type of the array.
Int GetArrayType(void);
193
F1ADDIN_AREA Formula One returns this constant when the argument is a range reference, as in the formula =SUM(A1:C5). F1ADDIN_ARRAY Not implemented in Formula One, this constant would represent an array, as in the Excel formula =SUM({1,2,3;4,5,6}).
IF1AddInArray::GetValue
Retrieves the value of the specified element in the array.
HRESULT GetValue( int int LPVARIANTARG nRow, nCol, pResult);
Where:
nRow nCol
is the row index of the element to be retrieved. is the column index of the element to be retrieved. points to the variant that will receive the elements value.
pResult
Return Value If nSheet, nRow, or nCol fall outside of the arrays boundaries, the return value is F1_E_REF. In this case, pResults variant is also set to F1_E_REF. If the function succeeds, Formula One returns S_OK, and sets pResults variant the value of the specified element in the array.
IF1AddInArray::IterStart IF1AddInArray::IterNext
Iterates through the non-empty elements of the array.
BOOL IterStart(void); BOOL IterNext(void);
To quickly iterate through the non-empty elements of an array, call IF1AddInArray::IterStart for the first element and IF1AddInArray::IterNext for each additional element until either of these functions returns FALSE. During each iteration, call IF1AddInArray::IterGetValue or IF1AddInArray::IterGetValueEx to retrieve the actual data. Formula One returns the elements in an arbitrary order. Routines that care about the location of the data should use IF1AddInArray::IterGetValueEx, which indicates the row and column of the current element. Using these functions may be much faster than individually examining each element in situations where a sparsely-populated array is expected.
194
Return Value TRUE if successful; FALSE if there are no more non-empty elements.
for (BOOL bGotOne = pAddInArray->IterStart(); bGotOne; bGotOne = pAddInArray->IterNext()) { // use IterGetValue or IterGetValueEx to // get the value of the current element }
IF1AddInArray::IterGetValue IF1AddInArray::IterGetValueEx
Retrieves the value of the array element last selected by IF1AddInArray::IterStart or IF1AddInArray::IterNext.
BOOL IterGetValue(LPVARIANTARG BOOL IterGetValueEx( LPINT pRow, LPINT pCol, LPVARIANTARG pResult); pResult);
Where:
pRow pCol
points to an integer that will receive the elements row index. points to an integer that will receive the elements column index. points to the variant that will receive the elements value.
pResult
Return Value If the last value returned by IF1AddInArray::IterStart or IF1AddInArray::IterNext was TRUE, the return value is TRUE. If the last value returned by IF1AddInArray::IterStart or IF1AddInArray::IterNext was FALSE, or if neither of those functions has yet been called, the return value is FALSE. When the return value is FALSE, no values will be placed in pRow, pCol, or pResult.
IF1AddInArrayEx interface
When an argument to an add-in function is a two- or three- dimensional area reference or a union, Formula One passes that reference or union to the add-in function as an IF1AddInArrayEx interface. (For two-dimensional area references, Formula One also implements the IF1AddInArray; the add-in function may use the interface that best suits its needs.)
195
IF1AddInArrayEx, not technically an array, provides a mapping mechanism for exposing a range in the workbook. In future versions of Formula One, the same interface may expose true arrays to the add-in function. This section describes the members of IF1AddInArrayEx.
IF1AddInArrayEx::Areas
Returns the number of areas in the array.
int Areas(void);
IF1AddInArrayEx::Rows
Returns the number of rows in an area of the array.
int Rows( int nArea);
Where:
nArea
IF1AddInArrayEx::Cols
Returns the number of columns in an area of the array.
int Cols( int nArea);
Where:
nArea
IF1AddInArrayEx::GetArrayType
Returns the type of the array.
int GetArrayType(void);
Return Value IF1AddInArrayEx returns one of the following constants: F1ADDIN_AREA: Formula One returns this constant when the argument is a 2D area reference, as in the formula =SUM(A1:C5). F1ADDIN_AREA3D: Formula One returns this constant when the argument is a 3D area reference, as in the formula =SUM(Sheet1:Sheet3!A1:C5). F1ADDIN_ARRAY: Not implemented in Formula One, this constant would represent an array, as in the Excel formula =SUM({1,2,3;4,5,6}).
196
F1ADDIN_REGION: Formula One returns this constant when the argument is a region reference, as in the formula =SUM((A1:C5,A10:C12)).
IF1AddInArrayEx::GetValue
Retrieves the value of the specified element in the array.
HRESULT GetValue( int int int LPVARIANTARG nArea, nRow, nCol, pResult);
Where:
nArea nRow nCol
is the row index of the element to be retrieved. is the column index of the element to be retrieved. points to the variant that will receive the elements value.
pResult
Return Value If nArea, nRow, or nCol, fall outside of the arrays boundaries, the return value is F1_E_REF. In this case, pResults variant is also set to F1_E_REF. If the function succeeds, the return value is S_OK, and pResults variant is set to the value of the specified element in the array.
IF1AddInArray::IterStart IF1AddInArray::IterNext
Iterates through the non-empty elements of the array.
BOOL IterStart(void); BOOL IterNext(void);
To quickly iterate through the non-empty elements of an array, call IF1AddInArrayEx::IterStart for the first element and IF1AddInArrayEx::IterNext for each additional element until either of these functions returns FALSE. During each iteration, call IF1AddInArrayEx::IterGetValue or IF1AddInArrayEx::IterGetValueEx to retrieve the actual data. Formula One returns the elements in an arbitrary order. Routines that care about the location of the data should use IF1AddInArrayEx::IterGetValueEx, which indicates the row and column of the current element. Using these functions may be much faster than individually examining each element in situations where a sparsely-populated array is expected.
197
Return Value TRUE if successful; FALSE if there are no more non-empty elements. Example
for (BOOL bGotOne = pAddInArrayEx->IterStart(); bGotOne; bGotOne = pAddInArrayEx->IterNext()) { // use IterGetValue or IterGetValueEx to // get the value of the current element }
IF1AddInArrayEx::IterGetValue IF1AddInArrayEx::IterGetValueEx
Retrieves the value of the array element last selected by IF1AddInArrayEx::IterStart or IF1AddInArrayEx::IterNext.
BOOL IterGetValue(LPVARIANTARG BOOL IterGetValueEx( LPINT pArea, LPINT pRow, LPINT pCol, LPVARIANTARG pResult); pResult);
Where:
pArea pRow pCol
points to an integer that will receive the elements row index. points to an integer that will receive the elements column index. points to the variant that will receive the elements value.
pResult
Return Value If the last value returned by IF1AddInArrayEx::IterStart or IF1AddInArrayEx::IterNext was TRUE, the return value is TRUE. If the last value returned by IF1AddInArrayEx::IterStart or IF1AddInArrayEx::IterNext was FALSE, or if neither of those functions has yet been called, the return value is FALSE. When the return value is FALSE, no values will be placed in pRow, pCol, or pResult.
198
199
// We handle arrays; we dont know about any other // interfaces, so all others are ignored here. IF1AddInArrayEx* pArray; if (SUCCEEDED(pArgs[0].punkVal>QueryInterface( IID_IF1AddInArrayEx, (LPVOID*)&pArray))) { // Copy the value of the top-left cell of the first // sheet or range to the result. pArray->GetValue(0, 0, 0, pResult); pArray->Release(); return S_OK; } } else // Copy the arguments value to the result. return ::CheckReturnValue(::VariantCopy(pResult, pArgs)); } return ::MakeErrorResult(pResult, F1_E_VALUE); } //////////////////////////////////////////////////////////////////// // GET.IN.RANGE function (::GetInRange) // // GET.IN.RANGE returns an item at a specified location // with a range. // Formula Cell Returned // -----------------------------------------------------// =GET.IN.RANGE(A11:C13,1,1) A11 // =GET.IN.RANGE(A11:C13,2,3) C12 // =GET.IN.RANGE(Sheet1:Sheet3!A11:C13,2,1,3) Sheet2!C11 // =GET.IN.RANGE((A1:C3,A11:C13),1,3,2) B3 // HRESULT CALLBACK GetInRange( LPVARIANTARG pResult, int, int nArgs, LPVARIANTARG pArgs) { if (nArgs == 3) { IF1AddInArray* pArray; // Try to get the array interface if (pArgs[0].vt == VT_UNKNOWN && SUCCEEDED( pArgs[0].punkVal->QueryInterface(IID_IF1AddInArray, (LPVOID*)&pArray))) { // Both coordinates must be of type double if (pArgs[1].vt == VT_R8 && pArgs[2].vt == VT_R8) { // If the coordinates are invalid, GetValue will put // #REF! in pResult, which is what we want.
200
201
hr = RegisterFunctionProc( L"RETURN.ME", // Name of the function as seen by the // end-user 0, // Reserved for future use; must be 0 ReturnMe, // Name of the function as implemented // in the DLL 1); // Number of arguments expected. if (SUCCEEDED(hr)) hr = RegisterFunctionProc( L"GET.IN.RANGE", 0, GetInRange, -1); if (SUCCEEDED(hr)) hr = RegisterInfoProc( F1AddInName. // // F1AddInDesc, // 0, // 0); //
Name of the add-in (defined at top of the file) Description of the add-in Reserved for future use; must be 0 Reserved for future use; must be 0
return hr; } //////////////////////////////////////////////////////////////////// // DllMain // // Initialization may be done here or in F1AddInInit--whichever best // suits your needs. See the Win32 API doc for more details about // this function. // BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; }
Tidestone
203
C H A P T E R
1 4
This chapter provides a complete alphabetical reference for the Formula One worksheet functions. Refer to Working With Datain this manual for additional information about using worksheet functions.
ABS
Description Syntax Returns the absolute value of a number. ABS ( number )
Parameter number Description Any number.
Remarks Examples
An absolute value does not display a positive or negative sign. These functions both return 1:
ABS(1) ABS(1)
See Also
SIGN
ACOS
Description Syntax Returns the arc cosine of a number. ACOS ( number )
Parameter number Description The cosine of the angle. The cosine can range from 1 to 1.
204
Remarks Examples
The resulting angle is returned in radians (from 0 to ). To convert the resulting radians to degrees, multiply the radians by 180/PI( ). This function returns 1.05:
ACOS(.5)
See Also
COS
ACOSH
Description Syntax Returns the inverse hyperbolic cosine of a number. ACOSH ( number )
Parameter number Description Any number equal to or greater than 1.
Examples
See Also
205
ADDRESS
Description Syntax Creates a cell address as text. ADDRESS ( row, column, ref_type [, a1] [, sheet] )
Parameter row column ref_type Description The row number for the cell address. The column number for the cell address. The cell reference type. Following are the valid values for this argument. Value Description 1 2 3 4 a1 Absolute Absolute row, relative column Relative row, absolute column Relative
The reference format. This argument must be TRUE( ) to represent an A1 reference format; Formula One does not support the R1C1 reference format. The name of an external worksheet view control. Omitting this argument assumes that the reference exists in the current spreadsheet.
sheet
Examples
See Also
206
AND
Description Syntax Returns True if all arguments are true; returns False if at least one argument is false. AND ( logical_list )
Parameter logical_list Description A list of conditions separated by commas. You can include as many as 30 conditions in the list. The list can contain logical values or a reference to a range containing logical values. Text and empty cells are ignored. If there are no logical values in the list, the error #VALUE! is returned.
Examples
See Also
NOT OR ROW
ASC
Description In DBCS (Far-East) systems, this functions returns a copy of text in which the double-byte characters are converted to single-byte characters, if possible. Characters that cannot be converted are left unchanged. ASC ( text )
Parameter text Description Text converted from double-byte characters to single-byte characters.
Syntax
207
ASIN
Description Syntax Returns the arcsine of a number. ASIN ( number )
Parameter number Description The sine of the resulting angle, ranging from 1 to 1.
Remarks Examples
The resulting angle is returned in radians (ranging from /2 to /2). To convert the resulting radians to degrees, multiply the radians by 180/PI(). This function returns 1.57:
ASIN(1)
See Also
ASINH PI SIN
ASINH
Description Syntax Returns the inverse hyperbolic sine of a number. ASINH ( number )
Parameter number Description Any number.
Examples
See Also
208
ATAN
Description Syntax Returns the arctangent of a number. ATAN ( number )
Parameter number Description The tangent of the angle.
Remarks Examples
The resulting angle is returned in radians, ranging from /2 to /2. To convert the resulting radians to degrees, multiply the radians by 180/PI( ). This function returns 1.29:
ATAN(3.5)
See Also
ATAN2
Description Syntax Returns the arctangent of the specified coordinates. ATAN2 ( x, y )
Parameter x y Description The x coordinate. The y coordinate.
Remarks
The arctangent is the angle from the x axis to a line with end points at the origin (0, 0) and a point with the given coordinates (x, y). The angle is returned in radians, ranging from to , excluding . This function returns 1.11:
ATAN2(3, 6)
Examples
See Also
ATAN2
209
ATANH PI TAN
ATANH
Description Syntax Returns the inverse hyperbolic tangent of a number. ATANH ( number )
Parameter number Description A number between 1 and 1, excluding 1 and 1.
Examples
See Also
AVERAGE
Description Syntax Returns the average of the supplied numbers. The result of AVERAGE is also known as the arithmetic mean. AVERAGE ( number_list )
Parameter number_list Description A list of numbers separated by commas. As many as 30 numbers can be included in the list, and the list can contain numbers or a reference to a range that contains numbers. Text, logical expressions, or empty cells in a referenced range are ignored. All numeric values (including 0) are used.
Examples
210
This function returns 134, the average of the values in the range C15:C17:
AVERAGE(C15:C17)
See Also
MIN MAX
CALL
Description Calls a procedure in a dynamic link library. There are two syntax forms of this function. When CALL is used with REGISTER.ID, as shown in syntax 1, the DLL is loaded and remains loaded until the program is dismissed. When CALL is used alone, as shown in syntax 2, the DLL is loaded, the function is called, and then the DLL is unloaded. Important This function is provided for advanced users only. If you use the CALL function incorrectly, you could cause errors that will require you to restart your computer. Syntax 1 Used with REGISTER.ID CALL(register_id, argument1, ...) Syntax 2 Used alone CALL(module_text, procedure, type_text, argument1, ...)
Parameter register_id argument1 module_text procedure Description The value returned by a previously executed REGISTER.ID function. The arguments to be passed to the procedure. Quoted text or reference specifying the name of the dynamic link library (DLL) that contains the procedure. Text specifying the name of the function in the DLL in Formula One. The function name is case dependent in Formula One. Text specifying the data type of the return value and the data types of all arguments to the DLL or code resource. The first letter of type_text specifies the return value. The data types you use for type_text are described in the following table.
type_text
211
E F G
H I J L M N
unsigned short int short int long int short int * short int * long int *
Remarks
For declarations made in C, it is assumed that your compiler defaults to 8-byte doubles, 2-byte short integers, and 4-byte long integers. In the Windows programming environment, all pointers should be far pointers. Pascal calling conventions are used for all functions called from DLLs. For most C compilers, you must add the Pascal keyword to the function declaration. If the return value for your custom function uses a pass-by-reference data type, a null pointer can be passed as the return value. The null pointer is interpreted as the #NUM! error value. For the F and G data types, a custom function can modify an allocated string buffer. If the return value type code is F or G, the value returned by the function is ignored. The list of function arguments is searched for the first data type that corresponds to the return value type. The current contents of the allocated string buffer is taken for the return value. 256 bytes is allocated for the argument; therefore, a function can return a larger string than it receives. You can use a single digit (n), with a value from 1 to 9, as the code for data_type. The variable in the location pointed to by the nth argument is modified instead of the return value; this process is referred to as modifying in place. The nth argument must be a pass-by-reference data type. In addition, you must declare the function void. For most C compilers, you can add the Void keyword to the function declaration.
212
Examples
Syntax 1 The following macro formula registers the GetTickCount function from 32-bit Microsoft Windows. GetTickCount returns the number of milliseconds that have elapsed since Microsoft Windows was started.
REGISTER.ID("Kernel32","GetTickCount","J")
Assuming that this REGISTER.ID function is in cell A5, after your macro registers GetTickCount, you can use the CALL function to return the number of milliseconds that have elapsed since Windows was started:
CALL(A5)
Syntax 2 On a worksheet, you can use the following CALL formula (syntax 2) to call the GetTickCount function:
CALL("Kernel32","GetTickCount","J!")
The ! in the type_text argument forces Formula One to recalculate the CALL function every time the worksheet recalculates. This updates the elapsed time whenever the worksheet recalculates.
CEILING
Description Syntax Rounds a number up to the nearest multiple of a specified significance. CEILING ( number, significance )
Parameter number significance Description The value to round. The multiple to which to round.
Remarks
Regardless of the sign of the number, the value is rounded up, away from zero. If number is an exact multiple of significance, no rounding occurs. If number or significance is non-numeric, the error #VALUE! is returned. When the arguments have opposite signs, the error #NUM! is returned.
Examples
213
See Also
CHAR
Description Syntax Returns a character that corresponds to the supplied ASCII code. CHAR ( number )
Parameter number Description A value between 1 and 255 that specifies an ASCII character.
Remarks Examples
The character and associated numeric code are defined by Windows in the ASCII character set. This function returns F:
CHAR(70)
See Also
CODE
214
CHOOSE
Description Syntax Returns a value from a list of numbers based on the index number supplied. CHOOSE ( index, item_list )
Parameter index item_list Description A number that refers to an item in item_list. A list of numbers, formulas, or text separated by commas. This argument can also be a range reference. You can specify as many as 29 items in the list.
Remarks
Index can be a cell reference; index can also be a formula that returns any value from 1 to 29. If index is less than 1 or greater than the number of items in item_list, #VALUE! is returned. If index is a fractional number, it is truncated to an integer. This function returns Q2:
CHOOSE(2,Q1, Q2, Q3, Q4)
Examples
See Also
INDEX
215
CLEAN
Description Syntax Removes all nonprintable characters from the supplied text. CLEAN ( text )
Parameter text Description Any worksheet information.
Remarks Examples
Text that is imported from another environment may require this function. This function returns Payments Due because the character returned by CHAR (8) is nonprintable:
CLEAN(Payments & CHAR(8) & Due)
See Also
CHAR TRIM
CODE
Description Syntax Returns a numeric code representing the first character of the supplied string. CODE ( text )
Parameter text Description Any string.
Remarks Examples
The numeric code and associated string are defined in your computers character set. This function returns 65:
CODE(A)
See Also
CHAR
216
COLUMN
Description Syntax Returns the column number of the supplied reference. COLUMN ( reference )
Parameter reference Description A reference to a cell or range. Omitting the argument returns the number of the column in which COLUMN is placed.
Examples
See Also
COLUMNS ROW
COLUMNS
Description Syntax Returns the number of columns in a range reference. COLUMNS ( range )
Parameter range Description A reference to a range of cells.
Example
See Also
COLUMN ROWS
217
CONCATENATE
Description Syntax Joins several text items into one item. CONCATENATE ( text1, text2, ....)
Parameter text1, text2, ... Description Up to 30 text items to be joined into a single text item. The text items can be strings, numbers, or single-cell references.
Remarks Examples
The & operator can be used instead of CONCATENATE to join text items. The following example returns Sale Price it is the same as typing Sale& & Price:
CONCATENATE ("Sale ", "Price")
Suppose in an inventory worksheet, C2 contains extruder1, C5 contains gaskets, and C8 contains the number 15. The following example returns Inventory currently holds 15 gaskets for extruder1.:
CONCATENATE ("Inventory currently holds ", C8, " ", C5," for ", C2)
See Also
COLUMN ROWS
COS
Description Syntax Returns the cosine of an angle. COS ( number )
Parameter number Description The angle in radians. If the angle is in degrees, convert the angle to radians by multiplying the angle by PI()/180.
Examples
218
See Also
COSH
Description Syntax Returns the hyperbolic cosine of a number. COSH ( number )
Parameter number Description Any number.
Examples
See Also
COUNT
Description Syntax Returns the number of values in the supplied list. COUNT ( value_list )
Parameter value_list Description A list of values. The list can contain as many as 30 values.
Remarks
COUNT only numerates numbers or numerical values such as logical values, dates, or text representations of dates. If you supply a range, only numbers and numerical values in the range are counted. Empty cells, logical values, text, and error values in the range are ignored.
219
Examples
See Also
COUNTA
Description Syntax Returns the number of nonblank values in the supplied list. COUNTA ( expression_list )
Parameter expression_list Description A list of expressions. As many as 30 expressions can be included in the list.
Remarks Examples
COUNTA returns the number of cells that contain data in a range. Null values ( ) are counted, but references to empty cells are ignored. This function returns 4:
COUNTA(32, 45, "Earnings", "")
This function returns 0 when the specified range contains empty cells:
COUNTA(C38:C40)
See Also
220
COUNTIF
Description Syntax Returns the number of cells within a range which meet the given criteria. COUNTIF ( range, criteria )
Parameter range criteria Description Range of cells you want to count. Number, expression, or text that defines which cells are counted.
See Also
DATE
Description Syntax Returns the serial number of the supplied date. DATE ( year, month, day )
Parameter year Description A number from 1900 to 2078. If year is between 1920 to 2019, you can specify two digits to represent the year; otherwise specify all four digits. A number representing the month (for example, 12 represents December). If a number greater than 12 is supplied, the number is added to the first month of the specified year. A number representing the day of the month. If the number you specify for day exceeds the number of days in that month, the number is added to the first day of the specified month.
month
day
Examples
See Also
221
YEAR
DATEVALUE
Description Syntax Returns the serial number of a date supplied as a text string. DATEVALUE ( text )
Parameter text Description A date in text format between January 1, 1900, and December 31, 2078. If you omit the year, the current year is used.
Examples
See Also
DAY
Description Syntax Returns the day of the month that corresponds to the date represented by the supplied number. DAY ( serial_number )
Parameter serial_number Description A date represented as a serial number or as text (for example, 06-21-94 or 21-Jun-94).
Examples
222
See Also
DAYS360
Description Returns the number of days between two dates based on a 360-day year (twelve 30day months). Use this function to help compute payments if your accounting system is based on twelve 30-day months. DAYS360 (start_date, end_date, [ method ] )
Parameter start_date, end_date method Description The two dates between which you want to know the number of days. A logical value that specifies whether the European or US method should be used in the calculation. If False (or omitted), the US (NASD) method is used. If True, the European method is used. The default is based on the local translation. It should be correct for your location.
Syntax
Remarks
start_date and end_date can be text strings using numbers to represent the month, day, and year (for example, 1/30/93 or 1-30-93), or they can be serial numbers representing the dates. If start_date occurs after end_date, DAYS360 returns a negative number. If method is set to False and start_date is the 31st of a month, it becomes equal to the 30th of the same month. If end_date is the 31st of a month and start_date is less than the 30th of a month, the ending date becomes equal to the 1st of the next month, otherwise the ending date becomes equal to the 30th of the same month. If method is set to True, start_dates or end_dates which occur on the 31st of a month become equal to the 30th of the same month. Note To determine the number of days between two dates in a normal year, you can use normal subtraction--for example, 12/31/93-1/1/93 equals 364.
Example
223
DB
Description Syntax Returns the real depreciation of an asset for a specific period of time using the fixeddeclining balance method. DB ( cost, salvage, life, period [, months] )
Parameter cost salvage life period months Description The initial cost of the asset. The salvage value of the asset. The number of periods in the useful life of the asset. The period for which to calculate the depreciation. The time units used to determine period and life must match. The number of months in the first year of the items life. Omitting this argument assumes there are 12 months in the first year.
Example
See Also
DBCS
Description In DBCS (Far-East) systems, this functions returns a copy of text in which the singlebyte characters are converted to double-byte characters, if possible. Characters that cannot be converted are left unchanged. ASC ( text )
Parameter text Description Text converted from single-byte characters to double-byte characters.
Syntax
224
DDB
Description Syntax Returns the depreciation of an asset for a specific period of time using the doubledeclining balance method or a declining balance factor you supply. DDB ( cost, salvage, life, period [, factor] )
Parameter cost salvage life period factor Description The initial cost of the asset. The salvage value of the asset. The number of periods in the useful life of the asset. The period for which to calculate the depreciation. The time units used to determine period and life must match. The rate at which the balance declines. Omitting this argument assumes a default factor of 2, the double-declining balance factor.
Remarks
The double-declining balance method uses an accelerated rate where the highest depreciation occurs in the first period, decreasing in successive periods. All arguments for this function must be positive numbers.
Example
See Also
DOLLAR
Description Syntax Returns the specified number as text, using the local currency format and the supplied precision. DOLLAR ( number [, precision] )
Parameter number precision Description A number, a formula that evaluates to a number, or a reference to a cell that contains a number. A value representing the number of decimal places to the right of the decimal point. Omitting this argument assumes two decimal places.
225
Note Local currency refers to the currency format for the current system, i.e., the one specified in Regional Settings in Control Panel Remarks Dollar will return the specified number format as text using currency format for the current system. If you wish to always convert to the US Dollar format, regardless of the language of your system, then use the USDOLLAR worksheet function. When using a US setting in Windows, this function returns $1023.79:
DOLLAR(1023.789)
US Example
UK Example
German Example
See Also
ERROR.TYPE
Description Syntax Returns a number corresponding to an error. ERROR.TYPE ( error_ref )
Parameter error_ref Description A cell reference.
226
Remarks
Example
See Also
ISERR ISERROR
EVEN
Description Syntax Rounds the specified number up to the nearest even integer. EVEN ( number )
Parameter number Description Any number, a formula that evaluates to a number, or a reference to a cell that contains a number.
Examples
See Also
227
EXACT
Description Syntax Compares two expressions for identical, case-sensitive matches. True is returned if the expressions are identical; False is returned if they are not. EXACT ( expression1, expression2 )
Parameter expression1 expression2 Description Any text. Any text.
Examples
See Also
LEN SEARCH
EXP
Description Syntax Returns e raised to the specified power. The constant e is 2.71828182845904 (the base of the natural logarithm). EXP ( number )
Parameter number Description Any number as the exponent.
Examples
See Also
LN LOG
228
FACT
Description Syntax Returns the factorial of a specified number. FACT ( number )
Parameter number Description Any non-negative integer. If you supply a real number, FACT truncates the number to an integer before calculation.
Examples
See Also
PRODUCT
FALSE
Description Syntax See Also Returns the logical value False. This function always requires the trailing parentheses. FALSE ( ) TRUE
FIND
Description Syntax Searches for a string of text within another text string and returns the character position at which the search string first occurs. FIND ( search_text, text [, start_position] )
Parameter search_text text start_position Description The text to find. If you specify an empty string (""), FIND matches the first character in text. The text to be searched. The character position in text where the search begins. The first character in text is character number 1. When you omit this argument, the default starting position is character number 1.
229
Remarks Examples
FIND is case-sensitive. You cannot use wildcard characters in the search_text. This function returns 12:
FIND("time", "Theres no time like the present")
See Also
FINDB
Description Syntax Searches for a string of text within another text string and returns the byte position at which the search string first occurs. FINDB ( search_text, text [, start_position] )
Parameter search_text text start_position Description The text to find. If you specify an empty string (""), FINDB matches the first byte in text. The text to be searched. The byte position in text where the search begins. The first byte in text is byte number 1. When you omit this argument, the default starting position is byte number 1.
Remarks
FINDB is case-sensitive. You cannot use wildcard characters in the search_text. start_position and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but FINDB should only be used in special applications that require distinctions between singlebyte and double-byte characters.
Examples
230
FIXED
Description Syntax Rounds a number to the supplied precision, formats the number in decimal format, and returns the result as text. FIXED ( number [, precision][, no_commas] )
Parameter number precision Description Any number. The number of digits that appear to the right of the decimal place. When this argument is omitted, a default precision of 2 is used. If you specify negative precision, number is rounded to the left of the decimal point. You can specify a precision as great as 127 digits. Determines if thousands separators (commas) are used in the result. Use 1 to exclude commas in the result. If no_commas is 0 or the argument is omitted, thousands separators are included (for example, 1,000.00).
no_commas
Examples
See Also
FLOOR
Description Syntax Rounds a number down to the nearest multiple of a specified significance. FLOOR (number, significance )
Parameter number significance Description The value to round. The multiple to which to round.
Remarks
Regardless of the sign of the number, the value is rounded down, toward zero. If number is an exact multiple of significance, no rounding occurs. If number or significance is non-numeric, #NAME? is returned. When the arguments have opposite signs, #NUM! is returned.
231
Examples
See Also
FV
Description Syntax Returns the future value of an annuity based on regular payments and a fixed interest rate. FV ( interest, nper, payment [, pv] [, type] )
Parameter interest nper payment pv Description The fixed interest rate. The number of payments in an annuity. The fixed payment made each period. The present value, or the lump sum amount, the annuity is currently worth. When you omit this argument, a present value of 0 is assumed. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed.
type
Remarks
The units used for interest must match those used for nper. For example, if the annuity has an 8 percent annual interest rate over a period of 5 years, specify 8 percent/12 for interest and 5*12 for nper. Cash paid out, such as a payment, is shown as a negative number. Cash received, such as a dividend check, is shown as a positive number.
Examples
232
See Also
HLOOKUP
Description Syntax Searches the top row of a table for a value and returns the contents of a cell in that table that corresponds to the location of the search value. HLOOKUP ( search_item, search_range, row_index )
Parameter search_item search_range Description A value, text string, or reference to a cell containing a value that is matched against data in the top row of search_range. A reference to the range (table) to be searched. The cells in the first row of search_range can contain numbers, text, or logical values. The contents of the first row must be in ascending order (for example, 2, 1, 0, 2...A through Z, False, True). Text searches are not case-sensitive. The row in search_range from which the matching value is returned. row_index can be a number from 1 to the number of rows in search_range. If row_index is less than 1, the error #VALUE! is returned. When row_index is greater than the number of rows in the table, the error #REF! is returned.
row_index
Remarks
HLOOKUP compares the information in the top row of search_range to the supplied search_item. When a match is found, information located in the same column and supplied row (row_index) is returned. If search_item cannot be found in the top row of search_range, the largest value that is less than search_item is used. When search_item is less than the smallest value in the first row of the search_range, the error #REF! is returned.
Examples
233
See Also
HOUR
Description Syntax Returns the hour component of the specified time in 24-hour format. HOUR ( serial_number )
Parameter serial_number Description The time as a serial number. The decimal portion of the number represents time as a fraction of the day.
Remarks Examples
The result is an integer ranging from 0 (12:00 AM) to 23 (11:00 PM). This function returns 9:
HOUR(34259.4)
See Also
234
IF
Description Syntax Tests the condition and returns the specified value. IF ( condition, true_value, false_value )
Parameter condition true_value false_value Description Any logical expression. The value to be returned if condition evaluates to True. The value to be returned if condition evaluates to False.
Example
This function returns Greater if the contents of A1 is greater than 10 and Less if the contents of A1 is less than 10:
IF(A1>10, "Greater", "Less")
See Also
INDEX
Description Syntax Returns the contents of a cell from a specified range. INDEX ( reference [, row] [, column] [, range_number] )
Parameter reference Description A reference to one or more ranges. If reference specifies more than one range, separate each reference with a comma and enclose reference in parentheses. For example, (A1:C6, B7:E14, F4). If each range in reference contains only one row or column, you can omit the row or column argument. For example, if reference is A1:A15, you can omit the column argument INDEX(A1:A15, 3,, 1). The row number in reference from which to return data. Column number in reference from which to return data. Specifies the range from which data is returned if reference contains more than one range. For example, if reference is (A1:A10, B1:B5, D14:E23), A1:A10 is range_number 1, B1:B5 is range_number 2, and D14:E23 is range_number 3.
235
Remarks
If row, column, and range_number do not point to a cell within reference, #REF! is returned. If row and column are omitted, INDEX returns the range in reference specified by range_number. The following examples use this worksheet.
Examples
See Also
INDIRECT
Description Syntax Returns the contents of the cell referenced by the specified cell. INDIRECT ( ref_text [, a1] )
Parameter ref_text a1 Description A reference to a cell that references a third cell. If ref_text is not a valid reference, the error #REF! is returned. The reference format. This argument must be TRUE() to represent an A1 reference format; Formula One does not support the R1C1 reference format.
Example
This function returns the contents of the cell that C1 references. If C1 contains D1, then the contents of D1is returned:
INDIRECT(C1)
236
See Also
OFFSET
INT
Description Syntax Rounds the supplied number down to the nearest integer. INT ( number )
Parameter number Description Any real number.
Examples
See Also
IPMT
Description Syntax Returns the interest payment of an annuity for a given period, based on regular payments and a fixed periodic interest rate. IPMT ( interest, per, nper, pv, [fv], [type] )
Parameter interest per nper pv fv type Description The fixed periodic interest rate. The period for which to return the interest payment. This number must be between 1 and nper. The number of payments. The present value, or the lump sum amount the annuity is currently worth. The future value, or the value after all payments are made. If this argument is omitted, the future value is assumed to be 0. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed.
237
Remarks
The units used for interest must match those used for nper. For example, if the annuity has an 8 percent annual interest rate over a period of 5 years, specify 8 percent/12 for interest and 5*12 for nper. Cash paid out, such as a payment, is shown as a negative number. Cash received, such as a dividend check, is shown as a positive number.
Examples
See Also
IRR
Description Syntax Returns internal rate of return for a series of periodic cash flows. IRR ( cash_flow [, guess] )
Parameter cash_flow Description A reference to a range that contains values for which to calculate the internal rate of return. The values must contain at least one positive and one negative value. During calculation, IRR uses the order in which the values appear to determine the order of the cash flow. Text, logical values, and empty cells in the range are ignored. The estimate of the internal rate of return. If no argument is supplied, a rate of return of 10 percent is assumed.
guess
Remarks
The internal rate of return is the interest rate received for an investment consisting of payments (specified by negative numbers) and investments (specified by positive numbers). IRR is calculated iteratively, cycling through the calculation until the result is accurate to .00001 percent. If the result cannot be found after 20 iterations, #NUM! is returned. When this occurs, supply a different value for guess.
238
Examples
See Also
ISBLANK
Description Syntax Determines if the specified cell is blank. ISBLANK ( reference )
Parameter reference Description A reference to any cell.
Remarks Example
If the referenced cell is blank, True is returned. False is returned if the cell is not blank. This function returns True if A1 is a blank cell:
ISBLANK(A1)
See Also
239
ISERR
Description Syntax Determines if the specified expression returns an error value. ISERR ( expression )
Parameter expression Description Any expression.
Remarks Example
If the expression returns any error except #N/A!, True is returned. Otherwise, False is returned. This function returns True if A1 contains a formula that returns an error such as #NUM!:
ISERR(A1)
See Also
ISERROR
Description Syntax Determines if the specified expression returns an error value. ISERROR ( expression )
Parameter expression Description Any expression.
Remarks Examples
If expression returns any error value, such as #N/A!, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!, True is returned. Otherwise, False is returned. This function returns True:
ISERROR(4/0)
This function returns False if A1 contains a formula that does not return an error.
ISERROR(A1)
See Also
ISBLANK
240
ISLOGICAL
Description Syntax Determines if the specified expression returns a logical value. ISLOGICAL ( expression )
Parameter expression Description Any expression.
Remarks Example
If expression returns a logical value, True is returned. Otherwise, False is returned. This function returns True because ISBLANK returns a logical value:
ISLOGICAL(ISBLANK(A1))
See Also
ISNA
Description Syntax Determines if the specified expression returns the value not available error. ISNA ( expression )
Parameter expression Description Any expression.
Remarks Example
If expression returns the #N/A! error, True is returned. Otherwise, False is returned. This function returns True if cell A1 contains the NA ( ) function or returns the error value #N/A!:
241
See Also
ISNONTEXT
Description Syntax Determines if the specified expression is not text. ISNONTEXT ( expression )
Parameter expression Description Any expression.
Remarks Examples
If expression returns any value that is not text, True is returned. Otherwise, False is returned. This function returns True if cell F3 contains a number or is a blank cell:
ISNONTEXT(F3)
See Also
242
ISNUMBER
Description Syntax Determines if the specified expression is a number. ISNUMBER ( expression )
Parameter expression Description Any expression.
Remarks
If expression returns a number, True is returned. Otherwise, False is returned. If expression returns a number represented as text (for example, 12), False is returned. This function returns True:
ISNUMBER(123.45)
Examples
See Also
ISREF
Description Syntax Determines if the specified expression is a range reference. ISREF ( expression )
Parameter expression Description Any expression.
Remarks Example
If expression returns a range reference, True is returned. Otherwise, False is returned. This function returns True:
ISREF(A3)
See Also
ISBLANK ISERR
243
ISTEXT
Description Syntax Determines if the specified expression is text. ISTEXT ( expression )
Parameter expression Description Any expression.
Remarks Example
If expression returns text, True is returned. Otherwise, False is returned. This function returns True:
ISTEXT("2nd Quarter")
See Also
LEFT
Description Syntax Returns the leftmost characters from the specified text string. LEFT ( text [, num_chars] )
Parameter text num_chars Description Any text string. The number of characters to return. This value must be greater than or equal to zero. If num_chars is greater than the number of characters in text, the entire string is returned. Omitting this argument assumes a value of 1.
Examples
244
See Also
MID RIGHT
LEFTB
Description Syntax Returns the leftmost byte from the specified text string. LEFTB ( text [, num_bytes] )
Parameter text num_bytes Description Any text string. The number of bytes to return. This value must be greater than or equal to zero. If num_bytes is greater than the number of bytes in text, the entire string is returned. Omitting this argument assumes a value of 1.
Remarks
num_bytes and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but LEFTB should only be used in special applications that require distinctions between singlebyte and double-byte characters. This function returns 2:
LEFTB("2nd Quarter")
Examples
LEN
Description Syntax Returns the number of characters in the supplied text string. LEN ( text )
Parameter text Description Any text string. Spaces in the string are counted as characters.
Examples
245
See Also
EXACT SEARCH
LENB
Description Syntax Returns the number of bytes in the supplied text string. LENB ( text )
Parameter text Description Any text string. Spaces in the string are counted as bytes.
Remarks
text and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but LENB should only be used in special applications that require distinctions between single-byte and double-byte characters. This function returns 11:
LENB("3rd Quarter")
Examples
LN
Description Syntax Returns the natural logarithm (based on the constant e) of a number. LN ( number )
Parameter number Description Any positive real number.
Remarks Examples
246
See Also
LOG
Description Syntax Returns the logarithm of a number to the specified base. LOG ( number [, base] )
Parameter number base Description Any positive real number. The base of the logarithm. Omitting this argument assumes a base of 10.
Examples
See Also
EXP LN LOG10
LOG10
Description Syntax Returns the base-10 logarithm of a number. LOG10 ( number )
Parameter number Description Any positive real number.
Examples
See Also
EXP LN
247
LOG
LOOKUP
Description Syntax Searches for a value in one range and returns the contents of the corresponding position in a second range. LOOKUP ( lookup_value, lookup_range, result_range )
Parameter lookup_value lookup_range Description The value for which to search in the first range. The first range to search and contains only one row or one column. The range can contain numbers, text, or logical values. To search lookup_range correctly, the expressions in the range must be placed in ascending order (for example, 2, 1, 0, 1, 2...A through Z, False, True). The search is not case-sensitive. A range of one row or one column that is the same size as lookup_range.
result_range
Remarks
If lookup_value does not have an exact match in lookup_range, the largest value that is less than or equal to lookup_value is found and the corresponding position in result_range is returned. When lookup_value is smaller than the data in lookup_range, #N/A is returned. The following examples use this worksheet.
Examples
See Also
248
LOWER
Description Syntax Changes the characters in the specified string to lowercase characters. Numeric characters in the string are not changed. LOWER ( text )
Parameter text Description Any string.
Examples
See Also
PROPER UPPER
249
MATCH
Description Syntax A specified value is compared against values in a range. The position of the matching value in the search range is returned. MATCH ( lookup_value, lookup_range, comparison )
Parameter lookup_value Description The value against which to compare. It can be a number, text, or logical value or a reference to a cell that contains one of those values. The range to search and contains only one row or one column. The range can contain numbers, text, or logical values. A number that represents the type of comparison to be made between lookup_value and the values in lookup_range. When you omit this argument, comparison method 1 is assumed. When comparison is 1, the largest value that is less than or equal to lookup_value is matched. When using this comparison method, the values in lookup_range must be in ascending order (for example, ...2, 1, 0, 1, 2..., A through Z, False, True). When comparison is 0, the first value that is equal to lookup_value is matched. When using this comparison method, the values in lookup_range can be in any order. When comparison is 1, the smallest value that is greater than or equal to lookup_value is matched. When using this comparison method, the values in lookup_range must be in descending order (for example, True, False, Z through A, ...2, 1, 0, 1, 2...).
lookup_range comparison
Remarks
When using comparison method 0 and lookup_value is text, lookup_value can contain wildcard characters. The wildcard characters are * (asterisk), which matches any sequence of characters, and ? (question mark), which matches any single character. When no match is found for lookup_value, #N/A is returned.
Examples
250
See Also
MAX
Description Syntax Returns the largest value in the specified list of numbers. MAX ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers, logical values, text representations of numbers, or a reference to a range containing those values. Error values or text that cannot be translated into numbers return errors. If a range reference is included in the list, text, logical expressions, and empty cells in the range are ignored. If there are no numbers in the list, 0 is returned.
Examples
See Also
AVERAGE MIN
251
MID
Description Syntax Returns the specified number of characters from a text string, beginning with the specified starting position. MID ( text, start_position, num_chars )
Parameter text start_position Description The string from which to return characters. The position of the first character to return from text. If start_position is 1, the first character in text is returned. If start_position is greater than the number of characters in text, an empty string ("") is returned. If start_position is less than 1, #VALUE! is returned. num_chars The number of characters to return. If num_chars is negative, #VALUE! is returned.
Remarks Examples
If start_position plus the number of characters in num_chars exceeds the length of text, the characters from start_position to the end of text are returned. This function returns Expenses:
MID("Travel Expenses", 8, 8)
See Also
252
MIDB
Description Syntax Returns the specified number of bytes from a text string, beginning with the specified starting position. MIDB ( text, start_position, num_bytes )
Parameter text start_position Description The string from which to return bytes. The position of the first byte to return from text. If start_position is 1, the first byte in text is returned. If start_position is greater than the number of bytes in text, an empty string ("") is returned. If start_position is less than 1, #VALUE! is returned. num_bytes The number of bytes to return. If num_bytes is negative, #VALUE! is returned.
Remarks
If start_position plus the number of bytes in num_bytes exceeds the length of text, the bytes from start_position to the end of text are returned. start_position, num_bytes, and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but MIDB should only be used in special applications that require distinctions between single-byte and double-byte characters.
Examples
253
MIN
Description Syntax Returns the smallest value in the specified list of numbers. MIN ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers, logical values, text representations of numbers, or a reference to a range containing those values. Error values or text that cannot be translated into numbers return errors. If a range reference is included in the list, text, logical expressions, and empty cells in the range are ignored. If there are no numbers in the list, 0 is returned.
Examples
See Also
AVERAGE MAX
MINUTE
Description Syntax Returns the minute that corresponds to the supplied date. MINUTE ( serial_number )
Parameter serial_number Description The time as a serial number. The decimal portion of the number represents time as a fraction of the day.
Remarks Examples
The result is an integer ranging from 0 to 59. This function returns 36:
MINUTE(34506.4)
254
See Also
MIRR
Description Syntax Returns the modified internal rate of return for a series of periodic cash flows. MIRR (cash_flows, finance_rate, reinvest_rate )
Parameter cash_flow Description A reference to a range that contains values for which to calculate the modified internal rate of return. The values must contain at least one positive and one negative value. During calculation, MIRR uses the order in which the values appear to determine the order of cash flow. Values that represent cash received should be positive; negative values represent cash paid. Text, logical values, and empty cells in the range are ignored. finance_rate reinvest_rate The interest rate paid on money used in the cash flow. The interest rate received on money reinvested from the cash flow.
Remarks Examples
The modified internal rate of return considers the cost of the investment and the interest received on the reinvestment of cash. The following examples use this worksheet.
255
See Also
MOD
Description Syntax Returns the remainder after dividing a number by a specified divisor. MOD ( number, divisor )
Parameter number divisor Description Any number. Any nonzero number. If divisor is 0, #DIV/0! is returned.
Examples
See Also
MONTH
Description Syntax Returns the month that corresponds to the supplied date. MONTH ( serial_number )
Parameter serial_number Description The date as a serial number or as text (for example, 06-21-94 or 21-Jun-94).
Remarks Examples
MONTH returns a number ranging from 1 (January) to 12 (December). This function returns 6:
MONTH("06-21-94")
256
See Also
N
Description Syntax Tests the supplied value and returns the value if it is a number. N ( value )
Parameter value Description A value or a reference to a cell containing a value to test.
Remarks
Numbers are returned as numbers, serial numbers formatted as dates are returned as serial numbers, and the logical function TRUE() is returned as 1. All other expressions return 0. This function returns 32467:
N(32467)
Examples
See Also
T VALUE
NA
Description Syntax Remarks Returns the error value #N/A, which represents not available. NA ( ) Use NA to mark cells that lack data without leaving them empty. Empty cells may not be correctly represented in some calculations. Although NA does not use arguments, you must supply the empty parentheses to correctly reference the function. See Also ISNA
257
NOT
Description Syntax Returns a logical value that is the opposite of its value. NOT ( logical )
Parameter logical Description An expression that returns a logical value such as True or False.
Remarks Examples
If logical is false, NOT returns True. Conversely, if logical is true, NOT returns False. This function returns False:
NOT(TRUE())
See Also
AND IF OR
NOW
Description Syntax Remarks Returns the current date and time as a serial number. NOW ( ) In a serial number, numbers to the left of the decimal point represent the date; numbers to the right of the decimal point represent the time. The result of this function changes only when a recalculation of the worksheet occurs. DATE DAY HOUR MINUTE MONTH SECOND TODAY WEEKDAY YEAR
See Also
258
NPER
Description Syntax Returns the number of periods of an investment based on regular periodic payments and a fixed interest rate. NPER ( interest, pmt, pf [, fv] [, type] )
Parameter interest pmt pf fv type Description The fixed interest rate. The fixed payment made each period. Generally, pmt includes the principle and interest, not taxes or other fees. The present value, the lump-sum amount that a series of future payments is currently worth. The future value, the balance to attain after the final payment. Omitting this argument assumes a future balance of 0. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed.
Examples
See Also
259
NPV
Description Syntax Returns the net present value of an investment based on a series of periodic payments and a discount rate. NPV ( discount_rate, value_list )
Parameter discount_rate value_list Description The rate of discount for one period. A list of as many as 29 arguments or a reference to a range that contains values that represent payments and income. During calculation, NPV uses the order in which the values appear to determine the order of cash flow. Numbers, empty cells, and text representations of numbers are included in the calculation. Errors and text that cannot be translated into numbers are ignored. If value_list is a range reference, only numeric data in the range is included in the calculation. Other types of data in the range, such as empty cells, logical values, text, and error values, are ignored.
Remarks
The time span NPV uses for calculation begins one period before the first cash flow date and ends when the last cash flow payment is made. This function is based on future cash flows. When your first cash flow occurs at the beginning of the first period, the first value must be added to the NPV result, not supplied as a value in value_list. This function returns 811.57:
NPV(8%, 12000, 3000, 3000, 3000, 7000)
Example
See Also
FV IRR PV
ODD
Description Syntax Rounds the specified number up to the nearest odd integer. ODD ( number )
Parameter number Description Any number, a formula that evaluates to a number, or a reference to a cell that contains a number.
260
Examples
See Also
OFFSET
Description Syntax Returns the contents of a range that is offset from a starting point in the spreadsheet. OFFSET ( reference, rows, columns [, height] [, width] )
Parameter reference rows Description A reference to a cell from which the offset reference is based. If you specify a range reference, #VALUE! is returned. The number of rows from reference that represents the upper-left cell of the offset range. A positive number represents rows below the starting cell; a negative number represents rows above the starting cell. If rows places the upper-left cell of the offset range outside the spreadsheet boundary, #REF! is returned. The number of columns from reference that represents the upper-left cell of the offset range. A positive number represents columns right of the starting cell; a negative number represents columns left of the starting cell. If columns places the upper-left cell of the offset range outside the spreadsheet boundary, #REF! is returned. A positive number representing the number of rows to include in the offset range. Omitting this argument assumes a single row. A positive number representing the number of columns to include in the offset range. Omitting this argument assumes a single column.
columns
height width
Remarks
OFFSET does not change the current selection in the worksheet. Because it returns a reference, OFFSET can be used in any function that requires or uses a cell or range reference as an argument.
261
Examples
This function returns the sum of the values in the range E3:F5:
SUM(OFFSET(A1, 2, 4, 3, 2))
OR
Description Syntax Returns True if at least one of a series of logical arguments is true. OR ( logical_list )
Parameter logical_list Description A list of conditions separated by commas. You can include as many as 30 conditions in the list. The list can contain logical values or a reference to a range containing logical values. Text and empty cells are ignored. If there are no logical values in the list, the error value #VALUE! is returned.
Example
See Also
AND IF NOT
PI
Description Syntax Remarks Returns the value of pi (), which is approximately 3.14159265358979 when calculated to 15 significant digits. PI ( ) Although PI does not use arguments, you must supply the empty parentheses to correctly reference the function. COS SIN TAN
See Also
262
PMT
Description Syntax Returns the periodic payment of an annuity, based on regular payments and a fixed periodic interest rate. PMT ( interest, nper, pv [, fv] [, type] )
Parameter interest nper pv fv type Description The fixed periodic interest rate. The number of periods in the annuity. The present value, or the amount the annuity is currently worth. The future value, or the amount the annuity will be worth. When you omit this argument, a future value of 0 is assumed. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed.
Remarks
PMT returns only the principal and interest payment, it does not include taxes or other fees. The units used for interest must match those used for nper. For example, if the annuity has an 8 percent annual interest rate over a period of 5 years, specify 8 percent/12 for interest and 5*12 for nper. Cash paid out, such as a payment, is shown as a negative number. Cash received, such as a dividend check, is shown as a positive number.
Examples
See Also
263
PPMT
Description Syntax Returns the principle paid on an annuity for a given period. PPMT ( interest, per, nper, pv, [fv], [type] )
Parameter interest per nper pv fv type Description The fixed periodic interest rate. The period for which to return the principle. The number of periods in the annuity. The present value, or the amount the annuity is currently worth. The future value, or the amount the annuity will be worth. When you omit this argument, a future value of 0 is assumed. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed.
Remarks
The units used for interest must match those used for nper. For example, if the annuity has an 8 percent annual interest rate over a period of 5 years, specify 8 percent/12 for interest and 5*12 for nper. This function returns 321.56:
PPMT(8%/12, 2, 48, 18000)
Examples
See Also
264
PRODUCT
Description Syntax Multiplies a list of numbers and returns the result. PRODUCT ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers, logical values, text representations of numbers, or a reference to a range containing those values. Error values or text that cannot be translated into numbers return errors. If a range reference is included in the list, text, logical expressions, and empty cells in the range are ignored. All numeric values, including 0, are used in the calculation.
Example
See Also
FACT SUM
PROPER
Description Syntax Returns the specified string in proper-case format. PROPER ( text )
Parameter text Description Any string.
Remarks
In proper-case format, the first alphabetic character in a word is capitalized. If an alphabetic character follows a number, punctuation mark, or space, it is capitalized. All other alphabetic characters are lowercase. Numbers are not changed by PROPER.
265
Examples
See Also
LOWER UPPER
PV
Description Syntax Returns the present value of an annuity, considering a series of constant payments made over a regular payment period. PV ( interest, nper, pmt [, fv] [, type] )
Parameter interest nper pmt fv type Description The fixed periodic interest rate. The number of payment periods in the investment. The fixed payment made each period. The future value, or the amount the annuity will be worth. When you omit this argument, a future value of 0 is assumed. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed.
Remarks
The units used for interest must match those used for nper. For example, if the annuity has an 8 percent annual interest rate over a period of 5 years, specify 8 percent/12 for interest and 5*12 for nper. Cash paid out, such as a payment, is shown as a negative number. Cash received, such as a dividend check, is shown as a positive number.
Examples
266
See Also
RAND
Description Syntax Remarks Example Returns a number selected randomly from a uniform distribution greater than or equal to 0 and less than 1. RAND ( ) Although RAND does not use arguments, you must supply the empty parentheses to correctly reference the function. This function returns a random number greater than or equal to 0 and less than 10:.
RAND()*10
RATE
Description Syntax Returns the interest rate per period of an annuity, given a series of constant cash payments made over a regular payment period. RATE ( nper, pmt, pv [, fv] [, type] [, guess] )
Parameter nper pmt pv fv type Description The number of periods in the annuity. The fixed payment made each period. Generally, pmt includes only principle and interest, not taxes or other fees. The present value of the annuity. The future value, or the amount the annuity will be worth. When you omit this argument, a future value of 0 is assumed. Indicates when payments are due. Use 0 if payments are due at the end of the period or 1 if payments are due at the beginning of the period. When you omit this argument, 0 is assumed. Your estimate of the interest rate. If no argument is supplied, a value of 0.1 (10 percent) is assumed.
guess
Remarks
RATE is calculated iteratively, cycling through the calculation until the result is accurate to .00001 percent. If the result cannot be found after 20 iterations, #NUM! is returned. When this occurs, supply a different value for guess.
267
Example
The following example returns the monthly interest rate of .0067; the annual interest rate (.0067 multiplied by 12) is 8 percent:
RATE(48, 439.43, 18000)
See Also
REGISTER.ID
Description Returns the register ID of the specified dynamic link library (DLL) that has been previously registered. If the DLL has not been registered, this function registers the DLL, and then returns the register ID. REGISTER.ID(module_text, procedure, type_text)
Parameter module_text procedure type_text Description The text specifying the name of the DLL that contains the function in Formula One. The text specifying the name of the function in the DLL in Formula One. The function name is case dependent in 32-bit Formula One. The text specifying the data type of the return value and the data types of all arguments to the DLL. The first letter of type_text specifies the return value. If the function or code resource is already registered, you can omit this argument. For a complete list of the data types available, see the type_text parameter of the CALL worksheet function.
Syntax
Remarks
For declarations made in C, it is assumed that your compiler defaults to 8-byte doubles, 2-byte short integers, and 4-byte long integers. In the Windows programming environment, all pointers should be far pointers. Pascal calling conventions are used for all functions called from DLLs. For most C compilers, you must add the Pascal keyword to the function declaration. If the return value for your custom function uses a pass-by-reference data type, a null pointer can be passed as the return value. The null pointer is interpreted as the #NUM! error value. For the F and G data types, a custom function can modify an allocated string buffer. If the return value type code is F or G, the value returned by the function is ignored. The list of function arguments is searched for the first data type that corresponds to the return value type. The current contents of the allocated string buffer is taken for the return value. 256 bytes is allocated for the argument; therefore, a function can return a larger string than it receives.
268
You can use a single digit (n), with a value from 1 to 9, as the code for data_type. The variable in the location pointed to by the nth argument is modified instead of the return value; this process is referred to as modifying in place. The nth argument must be a pass-by-reference data type. In addition, you must declare the function void. For most C compilers, you can add the Void keyword to the function declaration. Examples The following formula registers the GetTickCount function with Formula One and returns the register ID:
REGISTER.ID("Kernel32", "GetTickCount", "J!")
Assuming that GetTickCount was already registered on another sheet using the preceding formula, the following formula returns the register ID for GetTickCount:
REGISTER.ID("Kernel32", "GetTickCount")
REPLACE
Description Syntax Replaces part of a text string with another text string. REPLACE ( orig_text, start_position, num_chars, repl_text )
Parameter orig_text start_position Description The original text string. The character position where the replacement begins. If start_position is greater than the number of characters in orig_text, repl_text is appended to the end of orig_text. If start_position is less than 1, #VALUE! is returned. num_chars repl_text The number of characters to replace. If this argument is negative, #VALUE! is returned. The replacement text string.
Examples
See Also
269
REPLACEB
Description Syntax Replaces part of a text string with another text string. REPLACEB ( orig_text, start_position, num_bytes, repl_text )
Parameter orig_text start_position Description The original text string. The byte position where the replacement begins. If start_position is greater than the number of bytes in orig_text, repl_text is appended to the end of orig_text. If start_position is less than 1, #VALUE! is returned. num_bytes repl_text The number of bytes to replace. If this argument is negative, #VALUE! is returned. The replacement text string.
Remarks
REPLACEB is case-sensitive. You cannot use wildcard characters in the orig_text. start_position, num_bytes, and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but REPLACEB should only be used in special applications that require distinctions between single-byte and double-byte characters.
Examples
REPT
Description Syntax Repeats a text string the specified number of times. REPT ( text, number )
Parameter text number Description Any text string. The number of times you want text to repeat. If number is 0, empty text ("") is returned.
Remarks Example
The result of REPT cannot exceed 255 characters. This function returns error-error-error-:
REPT("error-", 3)
270
RIGHT
Description Syntax Returns the rightmost characters from the given text string. RIGHT ( text [, num_chars] )
Parameter text num_chars Description Any text string. The number of characters to return. The value must be greater than or equal to zero. If num_chars is greater than the number of characters in text, the entire string is returned. Omitting this argument assumes a value of 1.
Examples
See Also
LEFT MID
271
RIGHTB
Description Syntax Returns the rightmost bytes from the given text string. RIGHTB ( text [, num_chars] )
Parameter text num_bytes Description Any text string. The number of bytes to return. The value must be greater than or equal to zero. If num_bytes is greater than the number of bytes in text, the entire string is returned. Omitting this argument assumes a value of 1.
Remarks
num_bytes and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but RIGHTB should only be used in special applications that require distinctions between singlebyte and double-byte characters. This function returns r:
RIGHTB("2nd Quarter")
Examples
ROUND
Description Syntax Rounds the given number to the supplied number of decimal places. ROUND ( number, precision )
Parameter number precision Description Any value. The number of decimal places to which number is rounded. When a negative precision is used, the digits to the right of the decimal point are dropped and the absolute number of significant digits specified by precision are replaced with zeros. If precision is 0, number is rounded to the nearest integer.
Example
272
See Also
ROUNDDOWN
Description Syntax Rounds a number down. ROUNDDOWN ( number, numberOfDigits)
Parameter number numberOfDigits Description Any real number you want to round. The number of decimal places to which number is rounded. When a negative precision is used, the digits to the right of the decimal point are dropped and the absolute number of significant digits specified by precision are replaced with zeros. If precision is 0, number is rounded down to the nearest integer.
Example
See Also
273
ROUNDUP
Description Syntax Rounds the given number up to the supplied number of decimal places. ROUNDUP ( number, numberOfDigits)
Parameter number numberOfDigits Description Any value you want to round up. The number of decimal places to which number is rounded. When a negative precision is used, the digits to the right of the decimal point are dropped and the absolute number of significant digits specified by precision are replaced with zeros. If precision is 0, number is rounded up to the nearest integer.
Example
See Also
ROW
Description Syntax Returns the row number of the supplied reference. ROW ( reference )
Parameter reference Description A cell or range reference. Omitting this argument returns the row number of the cell in which ROW is entered.
Examples
See Also
COLUMN ROWS
274
ROWS
Description Syntax Returns the number of rows in a range reference. ROWS ( range )
Parameter range Description A reference to a range of cells.
Examples
See Also
COLUMNS ROW
SEARCH
Description Syntax Locates the position of the first character of a specified text string within another text string. SEARCH ( search_text, text [, start_position] )
Parameter search_text Description The text to find. The search string can contain wildcard characters. The available wildcard characters are * (asterisk), which matches any sequence of characters, and ? (question mark), which matches any single character. To search for an asterisk or question mark, include a tilde (~) before the character. text start_position The text to be searched. The character position where the search begins. If the number you specify is less than 0 or greater than the number of characters in text, #VALUE! is returned. Omitting this argument assumes a starting position of 1.
Remarks Examples
Text is searched from left to right, starting at the position specified. The search is not case-sensitive. If text does not contain the search string, #VALUE! is returned. This function returns 6:
275
See Also
SEARCHB
Description Syntax Locates the position of the first byte of a specified text string within another text string. SEARCHB ( search_text, text [, start_position] )
Parameter search_text Description The text to find. To search for an asterisk or question mark, include a tilde (~) before the character. The search string can contain wildcards. The available wildcard characters are * (asterisk), which matches any sequence of characters, and ? (question mark), which matches any single character. text start_position The text to be searched. The character position where the search begins. If the number you specify is less than 0 or greater than the number of bytes in text, #VALUE! is returned. Omitting this argument assumes a starting position of 1.
Remarks
Text is searched from left to right, starting at the position specified. The search is not case-sensitive. If text does not contain the search string, #VALUE! is returned. start-position and return value are expressed in bytes, so these values might differ on DBCS systems. On non-DBCS systems, these functions are identical, but SEARCHB should only be used in special applications that require distinctions between single-byte and double-byte characters.
Examples
276
SECOND
Description Syntax Returns the second that corresponds to the supplied date. SECOND ( serial_number )
Parameter serial_number Description The time as a serial number. The decimal portion of the number represents time as a fraction of the day.
Examples
See Also
SIGN
Description Syntax Determines the sign of the specified number. SIGN ( number )
Parameter number Description Any number.
Remarks Examples
SIGN returns 1 if the specified number is positive, 1 if it is negative, and 0 if it is 0. This function returns 1:
SIGN(123)
See Also
ABS
277
SIN
Description Syntax Returns the sine of the supplied angle. SIN ( number )
Parameter number Description The angle in radians. If the angle is in degrees, convert the angle to radians by multiplying the angle by PI( )/180.
Examples
See Also
ASIN PI
SINH
Description Syntax Returns the hyperbolic sine of the specified number. SINH ( number )
Parameter number Description Any number.
Examples
See Also
ASINH PI
278
SLN
Description Syntax Returns the depreciation of an asset for a specific period of time using the straightline balance method. SLN ( cost, salvage, life )
Parameter cost salvage life Description The initial cost of the asset. The salvage value of the asset. The number of periods of the useful life of the asset.
Example
See Also
SQRT
Description Syntax Returns the square root of the specified number. SQRT ( number )
Parameter number Description Any positive number. If you specify a negative number, the error #NUM! is returned.
Examples
See Also
SUMSQ
279
STDEV
Description Returns the standard deviation of a population based on a sample of supplied values. The standard deviation of a population represents an average of deviations from the population mean within a list of values. STDEV ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers or a reference to a range that contains numbers.
Syntax
Example
See Also
STDEVP
Description Returns the standard deviation of a population based on an entire population of values. The standard deviation of a population represents an average of deviations from the population mean within a list of values. STDEVP ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers or a reference to a range that contains numbers.
Syntax
Example
See Also
280
SUBSTITUTE
Description Syntax Replaces a specified part of a text string with another text string. SUBSTITUTE ( text, old_text, new_text [, instance] )
Parameter text old_text new_text instance Description A text string that contains the text to replace. You can also specify a reference to a cell that contains text. The text string to be replaced. The replacement text. Specifies the occurrence of old_text to replace. If this argument is omitted, every instance of old_text is replaced.
Examples
See Also
REPLACE TRIM
SUM
Description Syntax Returns the sum of the supplied numbers. SUM ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers, logical values, text representations of numbers, or a reference to a range containing those values. Error values or text that cannot be translated into numbers return errors. If a range reference is included in the list, text, logical expressions, and empty cells in the range are ignored.
281
Examples
This function returns 4000 when each cell in the range contains 1000:
SUM(A10:D10)
See Also
SUMIF
Description Syntax Returns the sum of the specified cells based on the given criteria. SUMIF ( range, criteria, sum_range)
Parameter range criteria Description The range of cells you want evaluated. A number, expression, or text that defines which cells are added. For example, criteria can be expressed as 15, 15, >15, cars. The actual cells to sum. These cells are only summed if their corresponding cells in range match the criteria. If this argument is omitted, the cells in range are summed.
sum_range
See Also
282
SUMPRODUCT
Description Syntax Multiplies the corresponding cells in the given ranges, then returns the sum of those products. SUMPRODUCT (range_list)
Parameter Description
range_list
Two or more range references that provide the sets of numbers you want to multiply. The first cell in the first range is multiplied with the first cell in the second range. Then all the products are summed.
Remarks
All the ranges in range_list must contain the same number of cells in the same arrangement. That is, if the first range is three rows deep and three columns wide, the second and subsequent ranges must also be three rows deep and three columns wide. The following examples use this worksheet.
Examples
283
SUMSQ
Description Syntax Squares each of the supplied numbers and returns the sum of the squares. SUMSQ ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers, logical values, text representations of numbers, or a reference to a range containing those values. Error values or text that cannot be translated into numbers return errors. If a range reference is included in the list, text, logical expressions, and empty cells in the range are ignored.
Example
See Also
SUM
SYD
Description Returns the depreciation of an asset for a specified period using the sum-of-years method. This depreciation method uses an accelerated rate, where the greatest depreciation occurs early in the useful life of the asset. SYD ( cost, salvage, life, period )
Parameter cost salvage life period Description The initial cost of the asset. The salvage value of the asset. The number of periods in the useful life of the asset. The period for which to calculate the depreciation. The time units used to determine period and life must match.
Syntax
Example
See Also
284
T
Description Syntax Tests the supplied value and returns the value if it is text. T ( value )
Parameter value Description The value to test.
Remarks Examples
Empty text ( ) is returned for any value that is not text. This function returns Report:
T("Report")
See Also
N VALUE
TAN
Description Syntax Returns the tangent of the specified angle. TAN ( number )
Parameter number Description The angle in radians. To convert a number expressed as degrees to radians, multiply the degrees by PI( )/180.
Examples
See Also
285
TANH
Description Syntax Returns the hyperbolic tangent of a number. TANH ( number )
Parameter number Description Any number.
Examples
See Also
TEXT
Description Syntax Returns the given number as text, using the specified formatting. TEXT ( number, format )
Parameter number format Description Any value, a formula that evaluates to a number, or a reference to a cell that contains a value. A string representing a number format. The string can be any valid format string including General, M/DD/YY, or H:MM AM/PM. The format must be surrounded by a set of double quotation marks. Asterisks cannot be included in format.
Examples
286
See Also
TIME
Description Syntax Returns a serial number for the supplied time. TIME ( hour, minute, second )
Parameter hour minute second Description A number from 0 to 23. A number from 0 to 59. A number from 0 to 59.
Examples
See Also
TIMEVALUE
Description Syntax Returns a serial number for the supplied text representation of time. TIMEVALUE ( text )
Parameter text Description A time in text format.
Examples
287
See Also
TODAY
Description Syntax Remarks See Also Returns the current date as a serial number. TODAY ( ) This function is updated only when the worksheet is recalculated. DATE DAY NOW
TRIM
Description Syntax Removes all spaces from text except single spaces between words. TRIM ( text )
Parameter text Description Any text string or a reference to a cell that contains a text string.
Remarks Example
Text that is imported from another environment may require this function. This function returns Level 3, Gate 45:
TRIM(" Level 3, Gate 45 ")
See Also
288
TRUE
Description Syntax See Also Returns the logical value True. This function always requires the trailing parentheses. TRUE ( ) FALSE
TRUNC
Description Syntax Truncates the given number to an integer. TRUNC ( number [, precision] )
Parameter number precision Description Any value. The number of decimal places allowed in the truncated number. Omitting this argument assumes a precision of 0.
Remarks Examples
TRUNC removes the fractional part of a number to the specified precision without rounding the number. This function returns 123.45:
TRUNC(123.456, 2)
See Also
289
TYPE
Description Syntax Returns the argument type of the given expression. TYPE ( expression )
Parameter expression Description Any expression.
Remarks
Examples
See Also
UPPER
Description Syntax Changes the characters in the specified string to uppercase characters. UPPER ( text )
Parameter text Description Any string.
290
Remarks Examples
Numeric characters in the string are not changed. This function returns 3RD QUARTER:
UPPER("3rd Quarter")
See Also
LOWER PROPER
USDOLLAR
Description Syntax Returns the specified number as text using the US Dollar format and the supplied precision. Omitting the precision argument assumes two decimal places. USDOLLAR ( number [, precision] )
Parameter number precision Description A number, a formula that evaluates to a number, or a reference to a cell that contains a number. A value representing the number of decimal places to the right of the decimal point. Omitting this argument assumes two decimal places.
Examples
See Also
291
VALUE
Description Syntax Returns the specified text as a number. VALUE ( text )
Parameter text Description Any text string, a formula that evaluates to a text string, or a cell reference that contains a text string. You can also specify a date or time in a recognizable format (for example, M/DD/YY for dates or H:MM AM/PM for time). If the format is not recognized, #VALUE! is returned.
Examples
See Also
VAR
Description Syntax Returns the variance of a population based on a sample of values. VAR ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers or a reference to a range that contains numbers.
Example
See Also
292
VARP
Description Syntax Returns the variance of a population based on an entire population of values. VARP ( number_list )
Parameter number_list Description A list of as many as 30 numbers, separated by commas. The list can contain numbers or a reference to a range that contains numbers.
Example
See Also
VDB
Description Syntax Returns the depreciation of an asset for a specified period using a variable method of depreciation. VDB ( cost, salvage, life, start_period, end_period [, factor] [, method] )
Parameter cost salvage life start_period end_period factor Description The initial cost of the asset. The salvage value of the asset. The number of periods in the useful life of the asset. The beginning period for which to calculate the depreciation. The time units used to determine start_period and life must match. The ending period for which to calculate the depreciation. The time units used to determine end_period and life must match. The rate at which the balance declines. Omitting this argument assumes a default of 2, which is the double-declining balance factor. A logical value that determines if you want to switch to straight-line depreciation when depreciation is greater than the declining balance calculation. Use True to maintain declining balance calculation; use False or omit the argument to switch to straight-line depreciation calculation.
method
293
Example
See Also
VLOOKUP
Description Syntax Searches the first column of a table for a value and returns the contents of a cell in that table that corresponds to the location of the search value. VLOOKUP ( search_item, search_range, column_index )
Parameter search_item search_range Description A value, text string, or reference to a cell containing a value that is matched against data in the top row of search_range. The reference of the range (table) to be searched. The cells in the first column of search_range can contain numbers, text, or logical values. The contents of the first column must be in ascending order (for example, 2, 1, 0, 2...A through Z, False, True). Text searches are not case-sensitive. The column in the search range from which the matching value is returned. column_index can be a number from 1 to the number of rows in the search range. If column_index is less than 1, #VALUE! is returned. When column_index is greater than the number of rows in the table, #REF! is returned.
column_index
Remarks
VLOOKUP compares the information in the first column of search_range to the supplied search_item. When a match is found, information located in the same row and supplied column (column _index) is returned. If search_item cannot be found in the first column of search_range, the largest value that is less than search_item is used. When search_item is less than the smallest value in the first column of the search_range, #REF! is returned.
294
Examples
See Also
WEEKDAY
Description Syntax Returns the day of the week that corresponds to the supplied date. WEEKDAY ( serial_number )
Parameter serial_number Description The date as a serial number or as text (for example, 06-21-94 or 21-Jun-94).
Remarks Examples
WEEKDAY returns a number ranging from 1 (Sunday) to 7 (Saturday). This function returns 1, indicating Sunday:
WEEKDAY(34399.92)
295
See Also
YEAR
Description Syntax Returns the year that corresponds to the supplied date. YEAR ( serial_number )
Parameter serial_number Description The date as a serial number or as text (for example, 06-21-94 or 21-Jun-94).
Examples
See Also
Tidestone
297
Index
A
About box displaying every 30 minutes xi, xii viewing xii AboutBox method xii ABS function 203 Absolute cell references 70 ACOS function 203 ACOSH function 204 Active cell 57, 58, 60 worksheet 50, 59 ActiveX Add-Ins in Visual Basic 183188 controls, adding to your application 1 AddColPageBreak method 153 Add-In functions creating 183 formula evaluation errors, chart 198 requirements for 184 AddPageBreak method 153 ADDRESS function 205 AddRowPageBreak method 153 AddSelection method 61 AlignHorizontal property 108 Aligning data 107108 Center toolbar button 43 Left Align toolbar button 43 Merge and Center toolbar button 43 Right Align toolbar button 43 SetAlignment method 52 AlignVertical property 108 Allocating memory 179 AllowArrows property 86 AllowCellTextDlg property 81, 86 AllowDelete property 58, 81, 86 AllowDesigner property 37 AllowEditHeaders property 81, 82, 121 AllowFillRange property 81, 86 AllowFormulas property 81, 85 AllowInCellEditing property 81 AllowMoveRange property 81, 86 AllowObjSelections property 62, 129, 146 AllowResize property 81, 86, 113 AllowSelections property 62 AllowTabs property 86 Anchors in HTML files 171 AND function 206 Arc command (Insert menu) 40 Arcs creating 123125 tool for 125 Area references as arguments 185 Arguments 2D area reference 192 2D, 3D, and union 192 and return values 191 in functions 73, 74 Arithmetic operators 68 Array arguments in functions 183 #ARRAY_FORMULA! error 72 Arrow keys 58, 85 ASIN function 206 ASINH function 207 ATAN function 208 ATAN2 function 208 ATANH function 209 Attach method 27, 30 AttachToSS method 27, 30 Autofill lists 74 adding 75 deleting 76 dragging for filling 88 AutoFillItems property 75, 76 AutoFillItemsCount method 75 Automatic recalculation 77 AutoPageNumber property 155 AutoRecalc property 77, 78 AVERAGE function 209 Axes page, in Chart Wizard 144
B
Background color, for graphical objects 133 Bar gap, on charts 143 Binding worksheet columns 169 Black and white printing 159 BlackAndWhite property 159 BLOBs reading and writing workbooks as 33 using multiple versions of Formula One and 33 Bold toobar button 43 Boolean 184 BorderColor property 117
298
Borders on cells 116118 on graphical objects 134135 BorderStyle property 117 BottomMargin property 154 Bring to Front command (Format menu) 41, 132 Built-in formats 99100 functions 7274 Button command (Insert menu) 40 Buttons creating 123125 formatting 137 tool for 125 ByVal 183
C
C++ Add-In API 189198 Calculating workbooks 7779 automatically 77 circular references when 79 CALL function 78 Cancel Insert Object command (Insert menu) 40 Cancelling data entry or editing 58 CEILING function 212 Cell reference in formula bar 46, 64 Cell references 6971 as function arguments 74 automatically entering 71 for check boxes 138 for dropdown list boxes 135, 138 in formulas 6971 in validation rules 82 of merged cells 109 to other workbooks 71 to other worksheets 70 with named row and column headings 121 Cells active 57, 58, 60 aligning data in 107108 attributes of 87 borders on 116118 clearing 97 deleting 98 displaying data types, with type markers 46 formatting to optimize memory 177 inserting 96 limiting number displayed on a worksheet 5556 locking 8182 merged 109110 naming 76 preventing resizing of 86
Index
ClearClipboard method 92 Clearing, cells 97 ClearRange method 52, 98 Clipboard, pasting from, with methods 92 Close command (File menu) 37 CODE function 215 Col property (F1FindReplaceInfo object) 95 ColHeadings property 159 ColHidden property 113 Colon (:), in range references 69 Color palette 48 Color toolbar button 43 Colors defining, in color palette 48 for borders of graphical objects 134 for cell borders 117 for cell data 107 for filling cells 118119 for graphical objects 133134 in number formats 105 maximum number, per workbook 180 printing as shades of gray 159 ColText property 52, 121 Column Autofit Selection command (Format menu) 40 Column Default Width command (Format menu) 41 COLUMN function 216 Column headings formatting 119 hiding 56 preventing changes to 82 preventing resizing of 86 printing 159 selecting 119 sizing 120 text of 120121 Column Hide command (Format menu) 40 Column Unhide command (Format menu) 41 Column width affected by default font 46 affected by displaying formulas 56 Column Width command (Format menu) 40 Columns applying number formats 101 building to optimize memory 177 deleting 98 freezing 116 headings (see column headings) inserting 96 maximum width 180 preventing selection of 62 print titles and 151 selecting 61 setting widths of 110114
299
Columns (continued) automatically 113 default 111 Columns command (Insert menu) 39 COLUMNS function 78, 216 ColWidth property 52, 113 ColWidthDlg method 52, 113 ColWidthTwips property 113 ColWidthUnits property 46, 114 Commas in cell references 70 in functions 73 Common Fixed and General Formats toolbar button 43 Comparison operators 68 CONCATENATE function 217 Conditional values, in number formats 105 Connect string 163 Constant values entering 6667 naming 76 using to optimize memory 177 Constants, not read in Visual C++ 2 Context menu 57 Converting from previous versions of Formula One 20 Copy Cell Format command (Edit menu) 38 Copy command (Edit menu) 38 Copy Format toolbar button 42 Copy toolbar button 42 CopyAll method 92 CopyDataFromArray method 93 CopyDataToArray method 93 Copying cell references 92 data across ranges 93 and optimizing performance 178 by dragging 57, 88 with drag-and-drop 88 with menu commands 91 with methods 92, 93 formulas 92 CopyRange method 52, 93, 178 CopyRangeEx method 7, 93, 178 COS function 217 COSH function 218 COUNT function 218 COUNTA function 219 COUNTIF function 220 CreateNewCellFormat method 117 Currency toolbar button 43 Currency, formatting numbers as 100 Custom data formats 102106 Cut command (Edit menu) 38
300
Cut toolbar button 42 Cutting cell references 92 data and optimizing performance 178 with menu commands 91 with methods 92, 93 formulas 92 CView-based applications, in Visual C++ 23 adding Formula One to 56
D
Data aligning 107108 clearing 98 filling worksheets with, and optimizing memory 179 formatting 99108 built-in formats for 99100 custom formats for 102106 inserting or updating in databases 167 ranges of (see ranges) retrieving from database 161170 sorting 98 types of 66 validating 82 Data entry 6365 constant values and 6667 formulas and 6772 limiting 8086 multi-line 65 properties for 64 with check boxes and dropdown list boxes 137 Data Grid Editor 145 Data structure 178 Data types, displaying with type markers 46 Databases 161170 binding worksheet columns in 169 connecting to 161, 162 disconnecting from 170 installing ODBC drivers for 161 PREPARE statements for 168, 170 querying 164 setting up 162 workbooks in 33 DataTransferRange property 93 Date and Time toolbar button 44 DATE function 220 Dates entering 67 formatting numbers as 101, 104 printing, in headers and footers 157 range of, accepted by Formula One x
Index
Documentation conventions xiii DOLLAR function 224 Dollar sign ($), in cell references 70 DoSafeEvents property 175 Double 184 Drag-and-drop copying data using 88 copying from other applications using 90 moving data using 88 Dragging copying using 88 filling from autofill lists using 88 preventing users from 86 Drawing and Forms Toolbar command (View menu) 39 Drawing toolbar 36 Drawing, graphical objects interactively 124 Drivers, ODBC 161 Dropdown List box command (Insert menu) 40 Dropdown list boxes creating 123125 formatting 135 input value cells for 138 items in 136 numbering scheme for items 137 selection values for 137139 tool for 125 Equal sign (=) in formulas 67 in functions 73 Error values, default alignment of 107 ERROR.TYPE function 225 Errors entering 67 function syntax 74 trapping, in PowerBuilder 20 worksheet formula 72 Escape key 58 EVEN function 226 Events, Formula One, in Visual C++ 7 EXACT function 227 Excel 4.x file format 32, 37 features ignored in Formula One 32 graphical objects 123 password-protected files 32 reading and writing files 32 validation rules 83 Exclamation mark (!), in sheet references 70 Executing PREPARE statements 170 Exit command (File menu) 38 EXP function 227 External references 71
301
E
Edge of worksheet, moving the active cell to 59 Edit menu, in Workbook Designer 38 Edit mode 58 See also In-cell editing EditClear method 52, 98 EditCopy method 92 EditCopyDown method 93, 178 EditCopyRight method 93, 178 EditCut method 92 EditDelete method 52, 98 EditDeleteSheets method 54 EditInsert method 52, 96, 98 EditInsertSheets method 53 EditPaste method 92 EditPasteValues method 92 Embedding Data in HTML files 171 EnableProtection property 52, 81 EndCol property 131 EndRow property 131 EnterMovesDown property 58, 86 Entry property 52, 64, 83 EntryRC property 52, 64, 83 EntrySRC property 52
F
F1AddInArray 184, 185 F1AddInArrayEx 184, 185 F1AddInInit 190 F1AddInRegisterFunctionProc 191 F1AddInRegisterInfoProc 190 F1Book API object 23 guidelines for using 30 understanding the 2627 F1BookView API object 23 guidelines for using 30 properties and methods that cannot be used with 29 understanding the 2730 F1CellFormat API object 24, 116, 117 F1EventArg API object 24 F1FileSpec API object 24 F1FindReplaceInfo API object 23 F1Functions 183 F1NumberFormat API object 24 F1ObjPos API object 24, 131 F1ODBCConnect API object 24, 162 F1ODBCQuery API object 24, 164 F1PateSetup API object 24 F1RangeRef API object 24, 61 F1Rect API object 24
302
F1ReplaceResults API object 24 FACT function 228 FALSE function 228 File menu, in Workbook Designer 37 FilePageSetupDlg method 52, 149 FilePageSetupDlgEx method 52 FilePrint method 149 FilePrintEx method 7, 150 FilePrintPreview method 160 FilePrintSetupDlg method 150 Fill command (Edit menu) 38 Filling preventing users from, with mouse 86 ranges 74 worksheets with data, and optimizing memory 179 Find and replace 94 using properties and methods 95 using the Workbook Designer 94 Find command (Edit menu) 39 Find dialog box 94 FIND function 228 FINDB function 229 FindDlg method 95 FindNext method x, 95 First Impression ActiveX control 141147, 161 Chart Designer 145 Data Grid Editor 145 using to draw charts 125, 141 FirstPageNumber property 155 FitPages property 158 FIXED function 230 FixedCol property 116 FixedRow property 116 Fixing rows and columns. See Freezing panes FLOOR function 230 Fonts changing default 46 default affects column width 46 formatting 106107 Formula Ones default 47 maximum number, per workbook 180 scripts in 47, 107 FooterMargin property 154 Footers formatting codes for 156157 margins for 154 printing 156157 Footnotes, for charts 144 Foreground color, for graphical objects 133 Format menu, in Workbook Designer 40 FormatAlignmentDlg method 52 FormatBorderDlg method 52 FormatCellsDlg method 52, 84, 102, 108, 118, 119
Index
Formulas (continued) entering 6772 errors in 72 external cell references in 71 functions and 7274 limiting entry of 85 maximum length 180 naming 76 operators in 68 operators precedence in 69 FormulaSRC property 52, 67 Fraction toolbar button 44 Fractions, formatting numbers as x, 100 Freeing memory 179 Freeze Panes command (Format menu) 41, 115, 116 Freezing panes 115116 example of 115 programmatically 116 Functions 7274, 203295 arguments for 74 cell references in 74 entering 73 maximum number of arguments 180 nesting 73 syntax errors in 74 using array arguments in 183 FV function 231 Graphical objects (continued) selection values for 137139 sizing 130132 using mouse mode when creating 126 Grid lines aligning graphical objects to 125, 130 hiding 56 printing 159 GridLines property 159
303
H
HAlign property 52 HdrHeight property 52, 120 HdrWidth property 52, 120 HeaderMargin property 154 Headers formatting codes for 156157 margins for 154 printing 156157 row and column (see row headings, column headings) Headings, creating using merged cells 109 Height command (Format menu) 112 Hiding calculations 27 column headings 56 graphical objects 135 grid lines 56 row headings 56 type markers 46 worksheet tabs 31, 46 zero values 56 HLOOKUP function 232 HOUR function 233 HTML 171 anchors 171 reading and writing file types 32 source files 171 writing a range to an HTML file 34
G
Gallery page, in Chart Wizard 143 GetArrayType 185 GetCellFormat method 81 GetIteration method 79 Goto command (Edit menu) 39 Graphical objects arranging layers of 132133 borders 134135 creating 123125 drawing interactively 124 editing polygons 139140 fill colors and patterns 133134 formatting 133137 hiding 135 identifying 126 input value cells for 138 moving 130132 naming 128 not supported in Excel 123 preventing selection of 62, 129 repositioning 57 resizing 57 selecting 128130
I
IDataObject 93 Identifying graphical objects by number 126 IF function 234 Images, importing 125 Import command (File menu) 37 In-cell editing 57 disabling 85 in-cell edit space x See also Edit mode INDEX function 78, 234
304
Index list of worksheets 50, 53, 71 Index numbers, of worksheets 31 INDIRECT function 78, 235 Insert menu, in Workbook Designer 39 InsertDlg method 52 InsertHTML method 34, 172 Inserting cells 96 columns 96 database data 167 rows 96 worksheets 49, 52 InsertRange method 52, 96 InsertSheets method 53 Installing, Formula One xxii Instancing property 183 INSTPROB.DOC file xii INT function 236 IntelliPoint mouse 57 Internet development events for 174 methods for 174 performing 173175 Intranet development events for 174 methods for 174 performing 173175 Invisible workbooks attaching 30 See also F1BookView API object IObjectSafety interface 171, 174 IPMT function 236 IRR function 237 ISBLANK function 238 ISERR function 239 ISERROR function 239 ISLOGICAL function 240 ISNA function 240 ISNONTEXT function 241 ISNUMBER function 242 ISREF function 242 ISTEXT function 243 Italic toolbar button 43 Items, in dropdown list boxes 136 IterationEnabled property 79 IterationMax property 79 IterationMaxChange property 79 Iterations circular references and 79 maximum number allowed in worksheet 180 IterNext and IterStart 185 IterStart and IterNext 185
K
Keyboard commands 58 limiting user access to 85 Keywords, in functions 73
L
Landscape printing orientation 157 LaunchDesigner method 36 Launching the Workbook Designer 36 Layout page, in Chart Wizard 144 Left Align toolbar button 43 LEFT function 243 LEFTB function 244 LeftMargin property 154 Left-to-right printing 158 LeftToRight property 158 Legends, for charts 144 LEN function 244 LENB function 245 Limiting data entry 8086 Line command (Insert menu) 40 Line feeds, cell entries and 65 LineColor property 135 Lines as borders on graphical objects 134135 creating 123125 formatting 134135 styles 134 tool for 124 LineStyle property 135 LineWeight property 135 List boxes. See Dropdown list boxes List, in dropdown list box 135 LN function 245 Locking cells 8182 displaying message 82 LOG function 246 LOG10 function 246 Logical property 52, 65 Logical values default alignment of 107 entering 67 LogicalRC property 52, 65 LogicalSRC property 52 LOOKUP function 247 LOWER function 248
Index
305
M
Main toolbar 36 Margins 154 MATCH function 249 MAX function 250 MaxCol property 31, 56 MaxRow property 31, 56 Member variables, in Visual C++ 45 Memory allocating 179 freeing 179 optimizing use of 177180 Menus, in Workbook Designer 3741 Merge and Center toolbar button 43 MergeCells property 109 Merging cells 109110 MID function 251 MIDB function 252 MIN function 253 MinCol property 31 Minimal recalcuation 78 MinimalRecalc property 79 MinRow property 31 MINUTE function 253 MIRR function 254 MOD function 255 Mode property 126 MONTH function 255 Months, automatically entering names of 74 Mouse actions of 57 drawing graphical objects 125 IntelliPoint mouse x limiting access to certain actions 86 selecting graphical objects 129 setting mode of 126 with checkboxes and dropdown list boxes 138 MoveRange method 52, 93, 178 Moving active cell 58 data and optimizing performance 178 with drag-and drop 88 with dragging 57 with menu commands 91 with methods 92, 93 graphical objects 130132 worksheet tabs 46 Multi-line data entry 58, 65, 108 preventing 85
N
N function 256 #N/A error 72 NA function 256 Name command (Insert menu) 40, 76 #NAME? error 72 Names built-in 77 cell 76 column heading 57 constant value 76 defining 76 formula 76 graphical object 128 maximum length 180 maximum number, per workbook 180 range 76 row heading 57 top left corner 57 worksheet 55, 57 worksheet and workbook, in headers and footers 157 Navigating in worksheets 5659 with keyboard commands 58 with mouse actions 57 with properties and methods 61 Nesting functions 73 New command (File menu) 37 New toolbar button 42 NextColPageBreak method 153 NextRowPageBreak method 153 NOT function 257 NOW function 78, 257 NPER function 258 NPV function 259 #NULL! error 72 #NUM! error 72 Number property 52, 65 NumberFormat property 52, 102 NumberFormatLocal property 52 Numbering, pages 155 NumberRC property 52, 65 Numbers as currency 100 as dates 101 as entries 66 as fractions 100 as percentages 103 as percents 100 as times 101 in scientific notation 100, 103 NumberSRC property 52 NumSheets property 53, 54
306
O
ObjAddItem method 136 ObjAddSelection method 129 ObjBringToFront method 127, 128, 132 ObjCellCol property 139 ObjCellRow property 139 ObjCellType property 139 ObjClick event 128, 129 ObjCreate method 123, 124 ObjCreatePicture method 124, 126 ObjDblClick event 128, 129 ObjDeleteItem method 136 Object command (Format menu) 41, 127, 128, 133, 134, 136, 137, 139, 146, 147 Objects Formula One 2324 in Visual C++ 6 graphical (see graphical objects) ObjFirstID method 127 ObjGetCell method 139 ObjGetItemCount method 136 ObjGetPos method 131, 132 ObjGetSelection method 127, 129 ObjGetSelectionCount method 130 ObjGotFocus event 128 ObjInsertItem method 136 ObjItem property 136 ObjItems property 136 ObjLostFocus event 128 ObjName property 128 ObjNameToID method 127 ObjNew method 123, 124, 141 ObjNewPicture method 124, 126 ObjNextID method 127 ObjPatternBG property 128, 133 ObjPatternFG property 128, 133 ObjPatternStyle property 128, 133 ObjPosToTwips method 132 ObjPosToTwipsEx method 132 ObjSelection property 130 ObjSendToBack method 127, 128, 132 ObjSetCell method 139 ObjSetPicture method 126 ObjSetPos method 131 ObjSetSelection method 129 ObjText property 137, 138 ObjValue property 138 ObjValueChanged event 128 ObjVisible property 135 ODBC 161170 binding of worksheet columns 169 configuring, in PowerBuilder 10
P
Page Break command (Insert menu) 40, 152 Page breaks, setting and removing 152153 Page numbers 155 in headers and footers 157 Page Setup command (File menu) 38, 151, 152, 154, 155, 156, 157, 158 PagesTall property 158 PagesWide property 158 PaletteEntry property 48 Paper size 158 PaperSize property 158 Parameters passed by reference, in PowerBuilder 20 Parentheses, in functions 73 Paste command (Edit menu) 38
Index
Paste Special command (Edit menu) 38 with merged cells 110 Paste toolbar button 42 Pasting data, with methods 92 merged cells 109 Patterns for filling cells 118119 for graphical objects 133134 Percent toolbar button 44 Percentages, formatting numbers as 103 Percents, formatting numbers as 100 PI function 261 Picture objects 124, 125 PMT function 262 Point, as measure for line weight 134 PolyEditMode property 139 Polygon command (Insert menu) 40 Polygon point editing 124, 139 Polygon Points command (Edit menu) 38 Polygons editing 139140 tool for 125 tool for edit mode 124 Portrait printing orientation 157 PowerBuilder 920 and application templates 11 and Formula One, web page 9 and ODBC 10 errors in 20 syntax 19 tutorials for Formula One 1018 working in 1920 working with databases in 1011, ??14 PPMT function 263 PREPARE statements 168, 170 Print area 77 Print Area command (File menu) 38 Print command (File menu) 38, 149 Print preview 159160 in Visual C++ 7 Print Preview command (File menu) 38, 159 Print Preview toolbar button 42 Print titles 77 Print Titles command (File menu) 38 Print toolbar button 42 PrintArea property 151 PrintAreaLocal property 151 PrintFooter property 156 PrintHeader property 156 Printing 149160 from print preview screen 160 headers and footers 156157
307
Printing (continued) in Visual C++ 7 margins 154 page breaks, setting and removing 152153 page numbers 155 page order 158 paper size 158 portrait or landscape 157 print area 150151 print preview 159160 row and column headings 159 scaling data 157 sizing data to fit pages 155 titles 151 PrintLandscape property 157 PrintPreviewDCEx method 7, 160 PrintPreviewEx method 160 PrintScale property 158 PrintTitles property 152 PrintTitlesLocal property 152 PRODUCT function 264 PROPER function 264 Properties command (Format menu) 41, 55, 56, 62, 82, 85 Properties command (Format Sheet menu) 86 Properties of Formula One in PowerBuilder 19 in Visual Basic 9 in Visual C++ 8 Properties, entering data with 64 Protecting the worksheet 8182 Protection command (Format menu) 41, 81 ProtectionDlg method 52 ProtectionHidden property 52, 81 ProtectionLocked property 52, 81 PV function 265
Q
Querying databases 164 QueryInterface 192
R
RAND function 78, 266 Ranges building to optimize memory 177 copying data across 93 deleting 98 editing, using methods 92 filling 74 naming 76 references as function arguments 74
308
Ranges (continued) references in formulas 6971 selecting 57, 60 source, for charts 141 writing to file 34 RATE function 266 Read command (File menu) 37 Read method 20, 33 Read toolbar button 42 ReadEx method 20, 33 ReadFromBlob method 33 Reading BLOBs 33 Excel-compatible files 32 Formula One files 32 HTML files 32 tabbed text files 32 Read-only, making workbook 8081 Recalc command (Tools menu) 41 Recalc method 78 Recalculation automatic workbook 77 circular references and 79 minimal 78 workbook 58, 7779 Rectangle command (Insert menu) 40 Rectangles creating 123125 tool for 124 #REF! error 72 Reference operators (for cell ranges) 68 References to cells. See Cell references Relative cell references 70 in validation rules 82 Remove Page Break command (Insert menu) 153 RemoveColPageBreak method 153 RemovePageBreak method 153 RemoveRowPageBreak method 153 Renaming worksheets 55 Repaint property 177 Repaint, disabling to optimize memory 177 Replace command (Edit menu) 39 Replace dialog box 94 REPLACE function 267 Replace method x, 95 REPLACEB function 269 ReplaceDlg method 95 REPT function 269 Retrieving data from databases 164 Right Align toolbar button 43 RIGHT function 270 RightMargin property 154 ROUND function 271
S
Safe events, understanding 175 Save As command (File menu) 37 Save command (File menu) 37 Save toolbar button 42 SaveFileDlg method 33, 171 SaveFileDlgEx method 33, 171 Scale for printing data 157 for viewing worksheets 56
Index
Scientific notation, formatting numbers as 100, 103 Scripts, in fonts 47, 107 Scroll lock key 59 Scrolling mode 57 SEARCH function 274 SEARCHB function 275 Searching for and replacing data 94 SECOND function 276 SelChange event 31 Select All Objects command (Edit menu) 38, 129 Selecting cells 6061 graphical objects 128130 row and column headings 119 rows and columns 57, 61 user options for 62 using the mouse 57 with properties and methods 61 with the keyboard 5859 with the mouse 60 worksheets 5051, 57 Selection property 61 SelectionCount property 61 SelectionEx property 61 SelHdrCol property 119 SelHdrRow property 119 SelHdrTopLeft property 119 Send to Back command (Format menu) 41, 132 Serial number, for Formula One x, xi Series labels, on charts 143 Set Print Area command (File menu) 150 Set Print Titles command (File menu) 152 SetAlignment method 52 SetBorder method 52 SetBorderEx method 52 SetCellFormat method 52, 81, 117 SetColWidth method 52, 114 SetColWidthAuto method 66, 114 SetColWidthTwips method 114 SetDefaultFont method 47 SetDefaultFontEx method 47 SetFont method 52 SetFontEx method 52, 107 SetHdrSelection method 119 SetIteration method 79 SetLineStyle method 128, 135 SetPageSetup method 52 SetPattern method 52, 118, 128, 133 SetProtection method 52 SetRowHeight method 52, 114 SetRowHeightAuto method 114 Setup.exe file xi SetValidationRule method 52
309
Sheet limits 56 Sheet Properties command (Format menu) 41, 55, 56, 62, 82, 85, 86, 116 Sheet property 31, 46 Sheet Protection command (Format menu) 41, 81 SheetName property 55 SheetSelected property 51, 53, 54 ShowColHeading property 56 ShowEditBar property 46, 64, 81 ShowEditBarCellRef property 46, 64 ShowFormulas property 56, 72 ShowGridLines property 56 ShowHScrollBar property 57 ShowLockedCellsError property 82 ShowRowHeading property 56 ShowTabs property 31, 46 ShowTypeMarkers property 46, 177 ShowVScrollBar property 57 ShowZeroValues property 56 SIGN function 276 SIN function 277 SINH function 277 Sizing graphical objects 130132 SLN function 278 Sort command (Edit menu) 38 Sort method 98 SortDlg method 98 Sorting data 98 Specifications 180 SQRT function 278 SSClearRange function call 98 SSDeleteRange function call 98 SSEditClear function call 98 Stacking, on charts 143 Standalone Workbook Designer 36 Standard Toolbar command (View menu) 39 StartCol property 131 StartRow property 131 Status Bar command (View menu) 39 STDEV function 279 STDEVP function 279 String 184 Strings, in formulas 68 Style page, in Chart Wizard 143 SUBSTITUTE function 280 SUM function 280 SUMIF function 281 SUMPRODUCT function 282 SUMSQ function 282 SYD function 283
310
T
T function 284 Tabbed text, reading and writing files 32 Tabs, worksheet displaying 46 enlarging space for 49 hiding 31, 46 TAN function 284 TANH function 285 Technical specifications 180 Templates, for applications in PowerBuilder 11 Text displayed next to check boxes 136 displayed on buttons 137 entering 67 obtaining formatted 101 TEXT function 285 Text operators 68 Text property 52, 65 TextRC property 52, 65 TextSRC property 52 Thread safety and F1Functions 184 3D charts 143 Tidestone Technologies, Inc. Case Tracking System xii contact information xii Europe office xiii website 171 TIME function 286 Times entering 67 formatting numbers as 101, 104 printing, in headers and footers 157 TIMEVALUE function 286 Title property 70 Titles, for charts 144 TODAY function 78, 287 Toggle Drawing Toolbar toolbar button 42 Toolbars 36, 4244 docking 37 Tools menu, in Workbook Designer 41 TopLeftText property 52, 121 TopMargin property 154 Top-to-bottom printing 158 TRIM function 287 TRUE function 288 TrueType fonts 47, 106 TRUNC function 288 TTF16.h file 2 Tutorials, using PowerBuilder 1018 2D charts 143
U
Underline toolbar button 43 Unfreeze Panes command (Format menu) 41 Uniform Data Transfer 93 Updating database data 167 Upgrading 20 UPPER function 289 USDOLLAR function 290 Users limiting access 46, 8086 to cells 8182 to certain keys 85 to changing row and column headings 82 to charts 146 to entering certain values 82 to entering formulas 85 to graphical objects 129 to mouse actions 86 to workbook areas 30 to workbooks 8081 setting selection options for 62
V
Validating data 82 Validation rules 82 ValidationFailed event 84 ValidationRule property 84 ValidationRuleDlg method 52 ValidationRuleLocal property 84 ValidationRuleLocalRC property 84 ValidationRuleRC property 84 ValidationText property 84 VAlign property 52 #VALUE! error 72 VALUE function 291 VAR function 291 Variant 184 VARP function 292 VDB function 292 Versions of Formula One 21, 33 View menu, in Workbook Designer 39 View scale, for worksheets 56 Views attaching 27, 30 information stored with 26 saving 32 working with 26
Index
ViewScale property 56 Visual Basic 89 adding the Formula One component 89 properties and methods, for Formula One 9 Visual basic using add-ins in 183 Visual C++ 18 adding the Formula One component 36 Formula One objects in 6 handling Formula One events 7 printing and previewing in 7 properties and methods, for Formula One 6, 8 serializing the Formula One control in 7 VLOOKUP function 293 Workbooks (continued) See also F1Book API object Worksheet command (Insert menu) 39, 53 Worksheet functions. See Functions Worksheets active 50 building to optimize memory 177 cells in borders for 116118 clearing 98 data alignment in 107108 deleting 98 inserting 96 locking 8182 data entry of 6365 constant values in 6667 formulas in 6772 limiting 8086 multi-line 65 data types in 66 deleting 54 display options 5556 external references in 71 formatting 99108 index list of 31, 50, 53, 71 inserting 49, 52 limiting rows and columns displayed 5556 maximum size 180 naming 55 navigating in 5659 performing tasks on multiple 50 preventing selection of 62 printing 149 referencing in cell references 70 selecting 5051 selection in cells 6061 rows and columns 61 sorting data in 98 tabs on 46 working with a group 51 Wrapper classes, in Visual C++ 6 Wrapping text 108 Write command (File menu) 37 Write method 33 WriteEx method 33 WriteRange method 34 WriteRangeEx method 7, 34 WriteToBlob method 33 WriteToBlobEx method 33 Writing a range of cell data 34 BLOBs 33
311
W
Web pages containing Formula One 173 WEEKDAY function 294 Weight, line 134 White space 177 Width command (Format menu) 112 Windows metafiles, importing 125 Windows Registration Database xi WordWrap property 52, 108 Workbook Designer 25, 3544 Edit menu commands 38 File menu commands 37 Format menu commands 40 Insert menu commands 39 keyboard commands 58 launching 36 menus 3741 mouse actions 57 standalone 36 toolbars 42 Tools menu commands 41 View menu commands 39 Workbooks attaching views to 26, 30 calculating 7779 automatically 77 circular references and 79 deleting worksheets from 54 denying user access to 8081 description of 24 display options 30, 4548 index sheet list in 50, 53 inserting worksheets in 49, 52 reading 32 retrieving, from database tables 33 selecting worksheets in 5051 writing 32
Writing (continued) Excel-compatible files 32 Formula One files 32 HTML files 32, 171 tabbed text files 32
X
X axis labels, on charts 144
Y
Y axis labels, on charts 144 YEAR function 295
Z
Z axis labels, on charts 144 Zero values, displaying or hiding 56 Zooming in and out in printing worksheets 157 in viewing worksheets 56