Microsoft KB Archive/70100

{|
 * width="100%"|

Using Computed Criteria on External Databases

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, versions 3.0, 4.0, 4.0a
 * Microsoft Excel for the Macintosh, version 4.0

-

SUMMARY
Using computed criteria in Microsoft Excel between two separate sheets performs differently in Microsoft Excel version 2.1 than it does in later versions. If you are setting up computed criteria on a separate sheet from the database, you need to use field names instead of cell references. This was not the case in earlier versions.

Steps to Reproduce Problem
 Start Excel and then open another new sheet. Now you should have two blank sheets open, Sheet1 and Sheet2.  On Sheet1, type the following data:

     A1: Name   B1: Age A2: Andy  B2: 23 A3: Joe   B3: 34 A4: Bill  B4: 12  Select cells A1:B4 and choose Set Database from the Data menu. On Sheet2, choose Define Name from the Formula menu and type the name Database in the Refers To: box. Type in Sheet1!database.  Remain on Sheet2 and type the following information:

     A1: 34  B1: A2:    B2:  =Sheet1!Age&lt;$A$1

Note: The formula in cell B2 will give you a #NAME? error if Age hasn't been defined, but that is OK. Also, make sure that your reference to a cell outside of the database is absolute (that is, $A$1 not A1).  Select cells B1:B2 and choose Set Criteria from the Data menu. Copy the field names Name and Age from Sheet1, and paste them into cells A4:B4 on Sheet2. While A4:B4 are still selected on Sheet2, choose Extract from the Data menu.</li></ol>

Notice that the records for Andy and Bill are extracted, which is correct. This works properly for version 2.1 and 3.0. However, if you substitute a cell reference for the word Age in the formula in cell B2 of Sheet2, your extract will be correct in version 2.1 but will be incorrect in later versions.

Example
If the formula in cell B2 of Sheet2 reads

=Sheet1!B2<$A$1

where B2 refers to the first data cell in the field Age, the extract for Microsoft Excel 2.1 will still correctly extract the records of Andy and Bill; however, in later versions, all the records in the database will be extracted.

In the case of versions 3.0 and 4.0, if your computed criteria formula results in TRUE, all records of the database are extracted and if the formula results in FALSE, none of the records are extracted. Microsoft Excel evaluates the formula once for each record and selects the record if the formula's result is TRUE or a number other than zero. In Microsoft Excel versions 3.0 and 4.0, the relative reference doesn't change because the formula is tested for each record; thus, it is necessary to use the field name.

Note: If you are setting up your database, criteria, and extract all on a single sheet in version 3.0 or 4.0, it is not necessary to use a field name instead of a reference.

For more information on computed criteria, query on the following keywords:

<pre class="FIXEDTEXT">  computed and criteria and references