以下代码将自动筛选器应用于工作表“'Grand Totals'!B1”中设置的日期条件的多个工作表,应用于工作表范围 A6,其格式为日期。第 1-5 行包含标题和公式。但是,第 3-5 行与从 A6 开始的过滤行一起消失。谁能明白为什么?据我所知,A6 行上方的所有内容都应该保持可见。再次感谢你的帮助。
子 ApplyFilterDate()
Dim Ws As Worksheet
Application.ScreenUpdating = False 'Turn off ScreenUpdating to speed filtering
For Each Ws In ActiveWorkbook.Worksheets
If Ws.Name <> "Grand Totals" Then
Ws.Activate
Ws.AutoFilterMode = False 'Remove any existing filters
Ws.Range("A6").AutoFilter Field:=1, Criteria1:=Range("'Grand Totals'!B1").Text
Range("G2").Activate
Center_it 'Puts next data entry cell in approximate center of screen
End If
Next
Sheet1.Activate
Range("B2").ClearContents
Range("B1").Interior.ColorIndex = 3 'Set color of cell showing filter date
Range("B1").Activate
Application.ScreenUpdating = True 'Turn on ScreenUpdating
结束子