The information in this article applies to:
SUMMARY
In Microsoft Excel, you can use the AutoFilter feature to filter a list
based on simple criteria. For example, if you have a list of salespeople
that has a column of names and a column containing each person's total
sales for the month, you can use the AutoFilter to show the records for the
top ten salespeople, based on their sales amounts for the month. The
ability to display the top 10 items in a list is a new feature of the
AutoFilter in Microsoft Excel versions 7.0 and 97. Excel adds the Top Ten feature to the drop-down list boxes that appear in all columns when you turn on the AutoFilter, but you can only use this feature on columns that contain numeric values.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspUse the following sample data for each of the sample macros in this article:
Macro to Display the Top Ten ItemsBecause the sample list contains only five records total, this sample macro filters the top two items in the list based on the Amount field:
If you run this macro from the sheet that contains the sample list, your
list displays rows 4 and 6 only.
NOTE: You can filter more (or fewer) than 10 items using the Top Ten feature. To change the number of items that appear when you run this macro, set the "Criteria1" argument to the amount that you want. Macro to Turn Off the AutoFilterThe following macro turns off the AutoFilter, and displays all of the records in the list. Note, if the AutoFilter is not on when you run this macro, the macro turns on the Autofilter, but because no criteria is specified, all records become visible.
Macro to Display the Bottom Ten ItemsWhen you click Top 10 from the AutoFilter list, the default setting is the top 10 items in the column. However, in the Top 10 AutoFilter dialog box, you can choose to display the Bottom 10 items instead.The following macro filters the bottom two items from the list based on the Amount field:
If you run this macro from the sheet that contains the list, your list displays rows 3 and 5 only.
NOTE: You can filter more (or fewer) than 10 items using the Top Ten feature. To change the number of items that appear when you run this macro, set the "Criteria1" argument to the amount that you want. REFERENCESFor more information about the AutoFilter, click Answer Wizard on the Help menu and type: tell me about the AutoFilter Additional query words: 8.00
Keywords : kbprg kbdta kbdtacode KbVBA |
Last Reviewed: September 14, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |