Consulting | Excel Examples

Dialog Box to Filter Data

Keywords: AutoFilter, Visual Basic for Applications, Criteria Range, InputBox

Description: Use a button, dialog box and simple VBA macro to filter data on a worksheet. When you click the button and enter values for year and month, the list is automatically filtered.

Tip: You can create an AdvancedFilter with a criteria range on a hidden worksheet. If you control the values in the hidden criteria range with a simple Visual Basic for Applications procedure, you can click on a button, enter criteria values with the InputBox method and change the filter. This technique if useful when you need to protect the criteria range and make the process of selection simple for the worksheet user.

Guide to the Example: The CriteriaValues worksheet and Module1 are hidden. To make them visible, use Format, Sheets, Unhide. Click on the button on the DataValues sheet and enter year and month to demonstrate the process.

Download File: Click Here
Tip: Click on the link above and choose "Save" to download the xls workbook to your hard drive or "Open" to open the workbook inside of your browser.

 

Last modified: May 21, 1996