Hi to all,
I'm new here.
I'm having a hard time writing a VBA code to disable filters in a file.
I found this code
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
but it works only on a simple file.
If I try it in the file I need to work with, it doesn't work.
I have this error (I have Excel in Italian language, so this error could be a little different in English)
"run time error 1004. 'ShowAllData' method of object '_Worksheet' failed".
What am I doing wrong?
Thank you.</code>
I'm new here.
I'm having a hard time writing a VBA code to disable filters in a file.
I found this code
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
Code:
</code>Sub AutoFiltroOff()<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.ActiveSheet
'azzera le condizioni del filtro automatico
'e mostra tutti i dati
If ws.AutoFilterMode Then
If ws.FilterMode Then
ws.ShowAllData
End If
End If
Set ws = Nothing
Set wb = Nothing
</code><code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">End Sub
but it works only on a simple file.
If I try it in the file I need to work with, it doesn't work.
I have this error (I have Excel in Italian language, so this error could be a little different in English)
"run time error 1004. 'ShowAllData' method of object '_Worksheet' failed".
What am I doing wrong?
Thank you.</code>