以下代码可以成功过滤Red Cells。
Sub Macro1()
Sheets("Sheet1").Range("A1:E500").AutoFilter Field:=1, Criteria1:=RGB(255, 0, 0), Operator:=xlFilterCellColor
End Sub
我正在寻找可以过滤不是红细胞的vba代码。
Sub FilterNotRedCells()
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
' Clear any existing filters
If ws.AutoFilterMode Then ws.AutoFilterMode = False
' Apply filter to show all cells that are not red
ws.Range("A1:E500").AutoFilter Field:=1, _
Criteria1:=RGB(255, 0, 0), _
Operator:=xlFilterCellColor, _
VisibleDropDown:=False
' Reapply the filter, excluding red cells (showing non-red)
ws.Range("A1:E500").AutoFilter Field:=1, _
Criteria1:=RGB(255, 0, 0), _
Operator:=xlFilterNoFill
End Sub