VBA - Copying a Certain Colored Row to Paste in Another Worksheet

Joined
Aug 24, 2011
Messages
2
Reaction score
0
Hello all,

I'm struggling with getting rows of data copied from one worksheet ("OK") to another worksheet("Expired Licenses") within the same workbook.

If a cell in column H in worksheet "OK" is red or magenta (background color), I want columns A-L of that row copied into "Expired Licenses" starting in A1. There can upwards of 60 or more rows that need to be copied. The first one should go from A1:L1 in "Expired Licenses". The second should go from A2:L2 and so on.

Here is what i have so far; Any help is much appreciated.
-The data starts in row 3

For i = 3 To Range("H500").End(xlUp).Row
If Cells(i, 8).Interior.ColorIndex = 3 Or Cells(i, 8).Interior.Color = RGB(255, 0, 255) Then
For m = 1 To 12
Cells(i, m).Copy
Sheets("Expired Licenses").Activate
Cells(i, m).Paste
Sheets("OK").Activate
Next
Else: End If
Next


Thanks,
Colin
 
Well, I didn't figure out how to copy and paste, but I figured out another way to do it:

counterD = 1
For i = 3 To Range("H500").End(xlUp).Row
If Cells(i, 8).Interior.ColorIndex = 3 Or Cells(i, 8).Interior.Color = RGB(255, 0, 255) Then
counterD = counterD + 1
For m = 1 To 12
Worksheets("Expired Licenses").Cells(counterD, m) = Worksheets("OK").Cells(i, m)
Sheets("OK").Activate
Next
Else: End If
Next
 
Back
Top