Search color than search value than copy both rows

emukiss10

Board Regular
Joined
Nov 17, 2017
Messages
201
Hello Guys!

A little tricky VBA request.

first part of code looks like this: (if cells have interior color diff than white add "NO" to selected row to column L)
Code:
 Dim CColour As Long
 Dim e As Long


    CColour = RGB(255, 255, 255)
    
    For e = 2 To Cells(Rows.count, "A").End(xlUp).row
        If Cells(e, "E").Interior.Color <> CColour Then
[B]        Cells(e, "L") = "NO"[/B]
        End If
    Next e

I would like to delete that Bold statement and add complicated one.

if color <> white then

take number from cell A2 Sheets(2) (if in row 2 col E color do not match ofc),
search it in cell column A Sheets(6)
and if found copy entire row Sheets(6) to Sheets(7) (Sheets(7) has headers so start from row 2)
and the row A2 Sheets(2) to next row Sheets(7)
- add one blank row (with no data for estetics) and go on till end of data in column A Sheets(2)





--------------------------------
Mayby this code can be of some use (copyright FLUFF)

Code:
   Dim Cl As Range
   Dim rng As Range
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Sheets(1).Range("F2", Sheets(1).Range("F" & Rows.count).End(xlUp))
         If Not .Exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      For Each Cl In Sheets(2).Range("E2", Sheets(2).Range("E" & Rows.count).End(xlUp))
         If Not .Exists(Cl.Value) Then
            If rng Is Nothing Then
               Set rng = Cl
            Else
               Set rng = Union(rng, Cl)
            End If
         End If
      Next Cl
   End With
   If Not rng Is Nothing Then rng.EntireRow.Delete


Best Regards
W.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,644
Members
449,461
Latest member
kokoanutt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top