3
是否有任何方法檢查工作表是否有任何過濾的數據(如果存在過濾的數據,則清除過濾器,否則什麼也不做)?我這裏有這樣的代碼,但我不知道該怎麼寫第二部分:過濾數據的VBA檢查表
Sub ProtectAll()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
With wSheet
If .AutoFilterMode Then
.ShowAllData
.Cells.Locked = True
.Cells.FormulaHidden = False
'.Range(wSheet.Cells(12, 1), wSheet.Cells(12, 18)).AutoFilter
'.Protect Password:=Pwd, AllowFiltering:=True
ElseIf ??? Then
End If
End With
Next wSheet
End Sub
參見Excel幫助[谷歌的excel自動篩選](http://www.google.com/search?hl=en&q=msdn+excel+autofilter+property)和[MSDN的excel自動篩選](http://msdn.microsoft.com/en-us /library/office/ff834384.aspx) –
@ d-stroyer謝謝你的建議。我發現重新應用過濾器可以做到這一點。 – atomoutside