我想要開啟excel檔案的時候,將檔案內的autofiler功能自動取消
測試了程式
Dim ws As Worksheet
For Each ws In Worksheets
If ws.AutoFilterMode Then
ws.AutoFilterMode = False
End If
Next ws
不管是設置在那的autofiler都能取消
但是將上述資料區域從range變成Table後就無法自動取消autofiler
所以重新寫了一個
Private Sub Workbook_Open()
Dim ws As Worksheet
Dim tbl As ListObject
For Each ws In ThisWorkbook.Worksheets
On Error Resume Next
Set tbl = ws.ListObjects("Table1")
On Error GoTo 0
If Not tbl Is Nothing Then
If tbl.AutoFilter.FilterMode Then
' Turn off autofilter
tbl.AutoFilter.ShowAllData
End If
End If
Set tbl = Nothing
Next ws
End Sub
依舊沒辦法將表格內的autofilter取消