Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi, good morning. Hope you are all well? please can you help me I have the code below where I am trying to transfer data from sheet1 to sheet2, but it has to be data that ihas coloured rows in red and green for example, and then to transfer the whole row from A - V. then to shift cells up and remove the blanks, I have tried code below but getting errors, hope you can help?
Code:
Sub copy_paste_based_on_cell_interior_rgb()
Const blue As String = "R:0 G:128 B:0"
Const purple As String = "R:255 G:0 B:0"
Dim i As Long
With Worksheets("Sheet1")
For i = 4 To .Range("A5" & .Rows.Count).End(xlUp).Row
Select Case rgb_valz(.Range("A" & i))
Case blue, purple
.Range("A" & i & ":V" & i).Copy Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
.Range("A" & i).Interior.Color = RGB(255, 0, 255)
End Select
Next i
End With
End Sub
Public Function rgb_valz(rng As Range) As String
rgb_valz = _
"R:" & rng.Interior.Color Mod 256 & _
" G:" & (rng.Interior.Color Mod 256 ^ 2) \ 256 & _
" B:" & rng.Interior.Color \ 256 ^ 2
End Function