In Excel 2003, and earlier versions, an AutoFilter allows only two criteria for each column. In Excel 2007 and later, you can select multiple criteria from each column in the table. See how to apply an Excel AutoFilter with multiple criteria in a range on the worksheet.
I’ve posted a few versions of the Excel Worksheet Data Entry Form, starting with the original version that Dave Peterson created. Thanks for your comments and suggestions, which give me ideas for enhancing it.
Over on the Contextures website, I’ve updated the AutoFilter Intro page, so it now covers the basics for Excel 2007 AutoFilters.
However, many people are still using an older version of Excel, so I’ve moved the original material to the Excel 2003 AutoFilter Basics page.
Improvements in AutoFilters
AutoFilters are easier to use in Excel 2007 and Excel 2010, and the filter and sort options are automatically added in the top row, if you format your list as an Excel Table.
Filter for Dynamic Date Ranges
Among the new AutoFilter features that were introduced in Excel 2007 are dynamic date ranges.
A Dynamic Date Range is one that changes automatically, as time moves forward.
For example, you could select Yesterday, which will represent a different date, every day that you open the Excel file.
AutoFilter Dynamic Date Range settings
Update Filters
Unfortunately, the dynamic dates are only semi-dynamic, and they don’t magically change when you open the workbook at a later date. You’ll need to update the filter to see the current information.
You can update the Excel 2007 AutoFilter manually, by clicking Reapply on the Excel Ribbon. Or, you could add a bit of code to the Workbook_Open event, to reapply the filters automatically.
Learn More About Excel 2007 AutoFilters
If you’re not familiar with the new features in Excel 2007 and Excel 2010 AutoFilters, you can learn more at Excel 2007 AutoFilter Basics.
_____________
The problem with putting a lovely red geranium on your table is that you can end up remodelling the kitchen! (Do you remember that magic geranium fable?)
Excel Weekly Meal Planner
Anyway, a while ago, I posted my Excel Weekly Meal Planner, which let you select meals for each weeknight, and print a grocery shopping list.
All was well in my kitchen, as I happily planned my meals with that useful workbook.
Then, JP from Code for Excel and Outlook, sent me a “geranium” — a copy of my Excel Christmas Planner, with a fancy new Excel Recipe Selector worksheet.
JP’s workbook has code that looks up recipes via web API, and returns the result to Excel.
Find a Recipe
For example, if you’re tired of steamed carrots, you can enter “Carrots” in the Recipes worksheet, and find more exotic recipes online.
Thanks JP! Your enhancement works great, and now it will be easy to spice up those holiday meals.
Find recipes for specific ingredient
Remodelling the Excel Weekly Meal Planner
Yes, JP’s Recipe Selector makes the Holiday Dinner Planner better, but it made my Excel Weekly Meal Planner look shabby!
It needed a recipe selector too. In his blog post, JP showed the code for using the API, and had a link to another function that’s required.
Add a Recipes Sheet
So, I copied the Recipes sheet from JP’s workbook, and inserted it into my weekly meal planner file. It worked great in its new location, and I just had to change a couple of references in the code.
But…now the rest of the weekly meal planner looked a bit run down, so I decide to remodel it. After a couple of coats of paint, a new backsplash and a shiny new pivot table, it’s ready for the open house.
Get the Update Version
You can tour the remodelled version on the Excel Weekly Meal Planner page on the Contextures website, and download a copy to help plan your meals.
Watch the Excel Weekly Meal Planner Video
To see a quick overview of how the Excel Weekly Meal Planner works, you can watch this short video.
In some workbooks, you want users to select one or more from a list of options.
Select Items in a List Box
To make it easier for people to enter data, you can add a List Box, with check boxes, to an Excel worksheet.
List Box on Data Entry Sheet
You wouldn’t want to have too many List Boxes on a worksheet, but it would be handy in a data entry form, like this one.
Tip: In worksheets where you need several cells with multiple options, you could use my technique for selecting multiple items from a data validation drop down.
Today, working on my Excel file was like riding a lazy snail through molasses in January — but slower!
Usually an Excel Advanced Filter is a speedy way to extract data from a table, but things weren’t working right in a sample file that I got last week.
And despite what my high school English teachers might think, you can’t mix too many similes, when trying to describe excruciating slowness.
Advanced Filter Macro Problem
The sample file had code that ran an Advanced Filter in Excel 2007.
The code ran quickly in Excel 2003, but screeched to a near halt in Excel 2007. What was the problem?
In the sections below, I detailed all the things I tried, while troubleshooting the slow macro problem.
Tip: You can skip to the end, to see what the unexpected problem was, and how I finally fixed the Advanced Filter macro.
There’s a video at the end of this post too, where I show the problem and the solution.
The Slow Filter Symptoms
When the code ran in Excel 2007, it looked like the extracted rows were being pasted in the second worksheet, one row at a time.
Aha! I should turn off the screen updating — a simple solution. You’d think.
Nope! Even with the screen updating turned off, the code barely crawled along.
It took almost 3 minutes to extract 1500 rows — maybe a millisecond faster than it ran with screen updating turned on. Who has that kind of time?
Guess Again
In the next round of solution guessing, I got rid of the few formulas in the worksheet and criteria range.
There wasn’t anything too complex, but maybe that was slowing things down.
I also changed calculation to manual at the start of the code, then set it to automatic at the end of the code.
Neither of those changes had any effect on the code’s speed.
Strip the Data Clean
In round 12 of testing (I’ve lost track of the test count), I copied the data, and pasted it as values into a new workbook.
The code ran like lightning. In July. With jet engines. Hmmm.
Maybe it was the formatting and styles in the original file that were slowing things down.
To test that theory, I formatted the original table with Normal style, which removed all the borders and fill colour.
That didn’t improve things, but when I removed the red fill from the heading cells, I noticed a red comment marker in one of the cells.
Whip Things Into Shape
Could a comment be the problem? That didn’t seem likely, but:
As soon as I deleted the comment, the code ran perfectly.
When I put the comment back, the macro slowed to a crawl again.
Curiouser and Curiouser
When I tried to create a sample file to demonstrate this problem, things got even stranger.
I created a table with a comment in the heading, and ran the code, expecting it to be slow. It ran quickly, in several tests.
Timing the Advanced Filter Macro
Add Shape to Worksheet
Next, I added a shape to the worksheet, and assigned a macro, to make it easier to run the code.
The code slowed down again!
Next, I deleted the shape, and the code was still slow, so I had to delete the comment to speed it up again.
The Verdict on Slow Advanced Filter Macro
If your Advanced Filters are running slowly in Excel 2007, try removing any comments in the table heading cells.
You could delete them at the start of a VBA procedure, run the filter, then add the comments at the end of the code.
Shapes + Comments = Trouble
The problem seems to occur if there are heading comments, and a shape is added later, as you can see in the short video demonstration below.
Fortunately, this problem appears to be fixed in Excel 2010, so if you upgrade, you should be able to have comments and shapes, without slowing down the Advanced Filters.
Another Solution
Update: In the comments, PDLobster suggests the following solution, to speed up the filters — thanks!
Turn off all filters
Select cell A1
Turn Wrap Text ON
Select the entire worksheet
Turn Wrap Text OFF
Watch the Video
To see the steps for reproducing and solving the Advanced Filter speed problem, you can watch this short Excel video.