将有条件格式化的彩色行复制到另一个 sheet

Copy the colored rows which are conditionally formatted to another sheet

我有 excel spreadhseet,在比较 TAT 值的天数后,它被有条件地格式化为不同的颜色。

现在,我想将每个彩色行复制到不同的 sheet 并将 sheet 命名为

我同意这可以通过手动过滤颜色来实现,可以通过 VBA 代码完成吗?

数据位于sheet的第6行。

此外,条件格式的颜色将来可能会发生变化,因此代码应覆盖放置在不同 sheet 中的彩色行。

如果可以通过 VBA 代码实现,请确认并回复解决方案。

请找到下图以加深理解。

这应该是您的起点。

Sub Test() 
    Range("A1").Select 
    Selection.AutoFilter 
    ActiveSheet.Range("$A:$D$" & Range("A" & rows.count).end(xlUp).Row).AutoFilter Field:=1, Criteria1:=RGB(255, 0 _ 
    , 0), Operator:=xlFilterCellColor 
    Range("$A:$D$" & lastr).Select 
    Selection.SpecialCells(xlCellTypeVisible).Select 
    Selection.Copy
    ThisWorkbook.Sheets.Add.Name = "Red"
    Sheets("Red").select
    Range("A" & Range("A" & rows.count).end(XlUp).row).Select 
    ActiveSheet.Paste 
    Application.CutCopyMode = False 
End Sub