Question : Advanced Filter Macro problems

Hi,
I have a macro set up to automatically create some lists on a worksheet when that worksheet is selected. The macro runs 4 advanced filters, each listing uniques entries from a column on another sheet. It then goes on to sort the newly created lists. Here are the 4 advanced filter lines:

    Range("Subledger").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("subl_top"), Unique:=True
    Range("cc").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("cc_top"), Unique:=True
    Range("SubArea").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("subarea_top"), Unique:=True
    Range("SCS_Area").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("scsarea_top"), Unique:=True

When I open the spreadsheet, these run fine the first time I select the sheet. However, when I activate the sheet another time only the 2nd advanced filter works - the others all make blank columns!

I've also had a situation where I've had 2 *identical* advanced filter macros, but only 1 will work!

Any idea what's going wrong here?

Thanks,
bassetjb

Answer : Advanced Filter Macro problems

Just a quick thought, haven´t tried it out though

In your code the criteria range isn´t given for any of the filters. Maybe that somehow is the reason it works the first time but not the second..like the criteria gets lost along the way or something.

Ex:
Range("Subledger").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=YourCriteriaRange, CopyToRange:=Range("subl_top"), Unique:=True
Random Solutions  
 
programming4us programming4us