Using Excel 2010 and have an issue that has be stumped. I have a worksheet (Supplier) that is protected. I un protect, apply Auto filter, save and then protect. When I run the below code, the Auto filter is being removed, why? The filters are on Cell A4: AO4. This is my code - it pulls data from a SQL SP into range A5:
Sheets("Supplier").Visible = True
'=== Code that fetches data from SQL server in to Cell A5 and below.....
Worksheets("Supplier").Protect Password:="xxxxxxxx", AllowFormattingCells:=True, AllowFiltering:=True
I'm using the same code elsewhere and the auto filters are not removed.
Fixed it. I have the below code in Activation code for the supplier worksheet. I deleted this and it now works:
If ActiveSheet.AutoFilterMode Then Cells.AutoFilter