how to insert and color these rows

F

Faye

How do I accomplish the following:

1. I would like to add a line of description, such as "Comparison
Results", to the Worksheets("Unique");

2. I would like to color those lines found in Sheet1 before they are
copied to Worksheets("Unique");

-----------------------------------------
With Worksheets("Sheet1")
Set rng1 = .Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
End With

With Worksheets("Sheet2")
Set rng2 = .Range(.Cells(1, 1), .Cells(Rows.Count, 1).End(xlUp))
End With

For Each cell In rng1
res = Application.Match(cell, rng2, 0)
If Not IsError(res) Then
Set rng3 = rng2(res)
Set rng4 = Worksheets("Match").Cells(Rows.Count,
1).End(xlUp)(2)
cell.EntireRow.Copy Destination:=rng4
Else
Set rng4 = Worksheets("Unique").Cells(Rows.Count,
1).End(xlUp)(2)
cell.EntireRow.Copy Destination:=rng4
End If
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top