Microsoft KB Archive/204061

= How to remove individual AutoFilter drop-down lists in Excel for Mac =

Article ID: 204061

Article Last Modified on 1/23/2007

-

APPLIES TO


 * Microsoft Excel 2004 for Mac
 * Microsoft Excel X for Mac
 * Microsoft Excel 2001 for Mac
 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q204061





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

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

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



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.

Syntax for the AutoFilter Method
Use the following syntax for the AutoFilter method:

.AutoFilter(Field, Criteria1, Operator, Criteria2, Visibledropdown)

where  is an expression that returns a Range object. 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 on 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
 Save and close any open workbooks, and then create a new workbook.  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  Start the Visual Basic Editor (press OPTION+F11). On the Insert menu, click Module.  In the module, type 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 </li> Run the Hide_Dropdown macro.</li> Switch to Microsoft Excel (press OPTION+F11).</li></ol>

The list in Sheet1 is filtered, and the visible cells are as follows: <pre class="fixed_text">  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: 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.

<div class="references_section">