Parece que macros mais antigas não estão a funcionar. Eu tenho a segurança adequada definida para executar macros VBA, mas quando eu tentei alguns métodos para limpar TODOS os filtros em uma planilha, eu recebi um erro de compilação.
Aqui está o que eu tentei:
Sub AutoFilter_Remove()
'Esta macro remove qualquer filtragem a fim de exibir todos os dados, mas não remove as setas do filtro
ActiveSheet.ShowAllData
Fim Sub
Eu tenho botões nas folhas para limpar todos os filtros para facilitar a utilização pelos utilizadores, uma vez que as folhas têm muitas colunas que têm filtros.
Tente algo assim:
Sub ClearDataFilters()
'Clears filters on the activesheet. Will not clear filters if the sheet is protected.
On Error GoTo Protection
If ActiveWorkbook.ActiveSheet.FilterMode Or _
ActiveWorkbook.ActiveSheet.AutoFilterMode Then _
ActiveWorkbook.ActiveSheet.ShowAllData
Exit Sub
Protection:
If Err.Number = 1004 And Err.Description = _
"ShowAllData method of Worksheet class failed" Then
MsgBox "Unable to Clear Filters. This could be due to protection on the sheet.", _
vbInformation
End If
End Sub
O .FilterMode' retorna verdadeiro se a planilha estiver em modo de filtro. ([Veja isto][1] para mais informações.) [Veja isto][2] para mais informações sobre o
.AutoFilter'.
E finalmente, isto irá fornecer mais informações sobre o método `.ShowAllData'.