ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to insert and color these rows (https://www.excelbanter.com/excel-programming/339914-how-insert-color-these-rows.html)

Faye[_2_]

how to insert and color these rows
 
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
-------------------------------------

Many thanks.



All times are GMT +1. The time now is 10:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com