I can't set the criteria for a vba advanced filter. I don't get an error on the assignment statement when running the program, but the filter fails, and the watch on the criteria variable says there's an application-defined or object-defined error.
All the code is in personal.xlsb. Another workbook has all the data, and at the outset, contains a sheet named "Parms" and another sheet named "Registered". Cells H2 and H3 in the Parms sheet contain the criteria for the advanced filter to be applied to the Registered sheet. The H column in Parms looks like this:
Row 1: FilterCrit ' column header
Row 2: VoterPct ' Name of the column in Registered that will be filtered. The name is the same on both Parms and Registered
Row 3: 101 ' The value to filter on
There is a worksheet variable, ParmSheet, set to Parms. That set is correct, and I can access other parms using it.
Here's the pertinent code:
' I've tried setting the criteria two different way, and get the same error.
or
' I know H2:H3 is the right range, because I tested it with Test1 = ParmSheet.Cells(2, 8) and Test2 = ParmSheet.Cells(3, 8)
What am I doing wrong? This code worked when I had the Parms sheet in personal.xlsb, and doesn't now that it's in the same workbook as the Registered file, but I don't know if that's significant. I have triple checked that there is only one column header VoterPct in the Registered sheet, and that both are spelled exactly the same.
Any help would be appreciated.
Bookmarks