Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: How to Remove Individual AutoFilter Drop-Down Lists


View products that this article applies to.

Summary

In Microsoft Excel 2000, you can programmatically hide an AutoFilter drop-down list for a specific field in a list by using a new argument for the Visual Basic for Applications AutoFilter method.

This article includes a sample Visual Basic macro that hides drop-down lists in a list to which you apply an AutoFilter.

NOTE: The only way to hide individual drop-down lists in a list to which you apply an AutoFilter is to use the AutoFilter method in a macro; you cannot manually hide the drop-down list.

↑ Back to the top


More information

Syntax for the AutoFilter Method

Microsoft 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 Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS Use the following syntax for the AutoFilter method
<expression>.AutoFilter(Field, Criteria1, Operator, Criteria2,
       Visibledropdown)
				
where <expression> is an expression that returns a Range object. <Expression> is required for the AutoFilter method. The following table lists the optional arguments for the AutoFilter method and the descriptions for the arguments.
   Argument         Description
   ----------------------------------------------------------------------

   Field            The integer offset of the field for which you want to
                    filter the list (the first field in your list has a
                    value of 1)

   Criteria1        The criteria for filtering the specified field

   Operator         Used to construct compound criteria

   Criteria2        Used in conjunction with Criteria1 and Operator to
                    build compound criteria

   Visibledropdown  True or False; false hides the drop-down list for the
                    specified field
				

Sample Macro

  1. Save and close any open workbooks, and then create a new workbook.
  2. In the new workbook, type the following data in Sheet1:
       A1: Name   B1: Area   C1: Amount
       A2: Bob    B2: East   C2: 1
       A3: Sue    B3: West   C3: 2
       A4: Bill   B4: East   C4: 3
       A5: Mary   B5: South  C5: 4
    					
  3. Start the Visual Basic Editor (press ALT+F11).
  4. On the Insert menu, click Module.
  5. In the module, type or paste the following code:
    Sub Hide_Dropdown()
    
        'Apply an AutoFilter to the list and hide the drop-down list
        'for the second field.
    
        Range("A1").AutoFilter field:=2, Criteria1:="East", _
            Visibledropdown:=False
    
    End Sub
    					
  6. Run the Hide_Dropdown macro.
  7. Switch to Microsoft Excel (press ALT+F11).
The list in Sheet1 is filtered, and the visible cells are displayed as follows:
   A1: Name   B1: Area   C1: Amount
   A2: Bob    B2: East   C2: 1
   A4: Bill   B4: East   C4: 3
				
There is no drop-down list for the Area field.

NOTE: The Visibledropdown argument for the AutoFilter method is not listed in the AutoFilter Method Help topic. Also, because the AutoFilter method is a write-only method, you cannot programmatically determine which fields in the list have drop-down lists that are hidden or unhidden.

↑ Back to the top


References

For more information about the AutoFilter method, click Microsoft Visual Basic Help on the Help menu, type autofilter method in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB213733, kbprogramming, kbhowto, kbdtacode

↑ Back to the top

Article Info
Article ID : 213733
Revision : 8
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 278