XL: Unexpected Results When Filtering Text Strings

Last reviewed: February 2, 1998
Article ID: Q134941
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

In Microsoft Excel, when you extract data from a list, you may receive unexpected results if your list contains numbers that are entered as text strings (by preceding the number with an apostrophe).

Numbers that are formatted as text strings and contain leading zeros may be extracted--this may not be the result you desire. For example, if your criteria is '012, the numbers '12, '012, 12, and '0012 all meet the criteria.

CAUSE

If the criteria is entered as a text string and not as part of the computed criteria, Microsoft Excel extracts all records that contain the text string at the beginning of the record even if that record is a numeric value.

RESOLUTION

To filter records in a list when the list contains an exact match to a numeric value entered as a text string, use computed criteria. For example, if you are working with data that resembles the following

   A1:  Number     B1:          C1:  Number
   A2:  '12        B2:          C2:  '012
   A3:  '012       B3:          C3:
   A4:  12         B4:          C4:
   A5:  '0012      B5:          C5:

type the following information into cells C1:C2 of the Criteria Range in the example above:

   C1: ExactNumber
   C2: =A2="012"

NOTE: The criteria name in the first row of the criteria range (cell C1) can be any name except the name of a database field; if you use the name of a database field, Microsoft Excel interprets the criteria as comparison criteria. You can also leave the cell blank.

REFERENCES

For more information about computed criteria, click the Search button in Help, and type:

   computed criteria

Choose the Show Topics button, select the topic, and choose Go To.


Additional query words: 5.00 5.00a 5.00c 7.00 8.00 97 XL97 98 XL98 filter
autofilter database
Keywords : xllist
Version : WINDOWS:5.0,5.0c,7.0,97; MACINTOSH:5.0,5.0a,98
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.