我有一堆工作表,每个工作表中只有一个表。我想运行一个代码,它将不过滤/显示所有工作表的所有数据。到目前为止,我已经写了下面的代码,但它没有给我我想要的结果。
dim ws1 as worksheet
On Error Resume Next
For Each ws1 In Worksheets
If ws1.FilterMode = True Then ws1.ShowAllData
Next ws1
On Error GoTo 0
请仔细阅读上述代码并予以修改。
由于 萨勒曼
答案 0 :(得分:1)
使用AutoFilterMode
属性..
Dim ws1 As Worksheet
On Error Resume Next
For Each ws1 In Worksheets
If ws1.AutoFilterMode = True Then ws1.AutoFilterMode = False
Next ws1
On Error GoTo 0
答案 1 :(得分:1)
您可能需要从Range.Hidden Property的角度以及Worksheet.ShowAllData方法解决此问题。方面。数据可能已被Range.AutoFilter Method以外的其他方式隐藏。
Dim w As Long
For w = 1 To Worksheets.Count
With Worksheets(w)
.UsedRange.Cells.EntireRow.Hidden = False
If .AutoFilterMode Then .ShowAllData
End With
Next w
答案 2 :(得分:0)
请根据您的要求试用此代码。
Sub test1()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
For Each ws In wb.Worksheets
If Not ws.AutoFilterMode = False Then
ws.AutoFilterMode = False
End If
Next
End Sub