R
ryguy7272
I tried the following macro to copy/paste non-colored cells to a sheet called
‘Copy If Non Color’. For some reason, all cells are copied to that sheet,
not just the non-colored cells. What am I doing wrong?
Sub noncolorcopier()
Dim w As Long
y = 1
Set z = ActiveSheet.UsedRange
nLastRow = z.Rows.Count + z.Row - 1
For w = 1 To nLastRow
If is_it_non_red(w) Then
Set rc = Cells(w, 1).EntireRow
Set rd = Sheets("Copy If Non Color").Cells(y, 1)
rc.Copy rd
y = y + 1
End If
Next
End Sub
Function is_it_non_red(w As Long) As Boolean
is_it_non_red = False
For x = 1 To Columns.Count
If Cells(w, x).Interior.ColorIndex = xlNone Or Cells(w,
x).Interior.ColorIndex = xlWhite Then
is_it_non_red = True
Exit Function
End If
Next
End Function
Regards,
Ryan---
‘Copy If Non Color’. For some reason, all cells are copied to that sheet,
not just the non-colored cells. What am I doing wrong?
Sub noncolorcopier()
Dim w As Long
y = 1
Set z = ActiveSheet.UsedRange
nLastRow = z.Rows.Count + z.Row - 1
For w = 1 To nLastRow
If is_it_non_red(w) Then
Set rc = Cells(w, 1).EntireRow
Set rd = Sheets("Copy If Non Color").Cells(y, 1)
rc.Copy rd
y = y + 1
End If
Next
End Sub
Function is_it_non_red(w As Long) As Boolean
is_it_non_red = False
For x = 1 To Columns.Count
If Cells(w, x).Interior.ColorIndex = xlNone Or Cells(w,
x).Interior.ColorIndex = xlWhite Then
is_it_non_red = True
Exit Function
End If
Next
End Function
Regards,
Ryan---