skatun
skatun

Reputation: 877

Remove all active filters from sheet in excel

I am working with tables in excel and I want to remove all filter that has been set in any of my 52 columns, remove bold, colors etc(back to normal formatting).

Somehow my code does not do this, any idea where the issue might be?

'Clears filters on the activesheet. Will not clear filters if the sheet is protected.
On Error Resume Next
If ActiveWorkbook.ActiveSheet.FilterMode Or ActiveWorkbook.ActiveSheet.AutoFilterMode Then
   ActiveWorkbook.ActiveSheet.ShowAllData
End If

 'in case the sheet is protected
ActiveWorkbook.Sheets("List").Cells.EntireColumn.Hidden = False

Upvotes: 2

Views: 21393

Answers (4)

skatun
skatun

Reputation: 877

This solved it:

ActiveWorkbook.Worksheets("List").ListObjects("FilterParts").Sort.SortFields.Clear
ActiveSheet.ShowAllData

However how can I sort this column

Range("FilterParts[[#Headers],[POS NUMBER]]").Select

so that it shows everything except blanks?

Upvotes: 0

Karthick Gunasekaran
Karthick Gunasekaran

Reputation: 2713

Please try with the below

Cells.AutoFilter

Upvotes: 0

user6028892
user6028892

Reputation:

If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData

Upvotes: 1

Vityata
Vityata

Reputation: 43585

Can you try with this one instead:

ActiveSheet.AutoFilter.ShowAllData

It may work.

Upvotes: 0

Related Questions