Вы можете сделать что-то вроде этого:
Option Explicit
Sub CopyByColor()
Dim shtSrc As Worksheet, shtDest As Worksheet
Dim lastRowSrc As Long, nextRowDest As Long, i As Long
Set shtSrc = Worksheets("Sheet1")
Set shtDest = Worksheets("Sheet2")
lastRowSrc = shtSrc.Cells(Rows.Count, 1).End(xlUp).Row
nextRowDest = shtDest.Cells(Rows.Count, 1).End(xlUp).Row + 1
For i = 1 To lastRowSrc
'only check used cells in the row...
If IsColorMatch(Application.Intersect(shtSrc.Rows(i), shtSrc.UsedRange)) Then
shtSrc.Rows(i).Copy shtDest.Cells(nextRowDest, 1)
nextRowDest = nextRowDest + 1
End If
Next i
End Sub
Function IsColorMatch(rng As Range)
Const INDEX_COLOR As Long = 35
Const INDEX_COLOR_BAD As Long = 3 'or whatever...
Dim c As Range, indx
IsColorMatch = False '<< default
For Each c In rng.Cells
indx = c.Interior.ColorIndex
If indx = INDEX_COLOR Then
IsColorMatch = True
Elseif indx = INDEX_COLOR_BAD Then
IsColorMatch = False
Exit Function '<< got a "bad" color match, so exit
End If
Next c
End Function
РЕДАКТИРОВАТЬ : другая реализация IsColorMatch
с использованием подхода "найти форматирование":
Function IsColorMatch(rng As Range) As Boolean
If RangeHasColorIndex(Selection.EntireRow, 6) Then
IsColorMatch = Not RangeHasColorIndex(Selection.EntireRow, 3)
Else
IsColorMatch = False
End If
End Function
Function RangeHasColorIndex(rng As Range, indx As Long)
With Application.FindFormat
.Clear
.Interior.ColorIndex = indx
End With
RangeHasColorIndex = Not rng.Find("", , , , , , , , True) Is Nothing
End Function