shantraj.antin@gmail.com
Member
I have to work sheets Sheet1 and Sheet2 with set of data. I hva to idnetify duplicate values from sheet2 IDs to sheet 1 Id and color code the same formate like what the sheet 2 deal ID has. I am done till idnetification of duplicates but struck in fromating the color code of sheet 2 line item to sheet 1 line item,
Code is,
Sub findDuplicates()
' code to find duplicates in 2 different worksheets
Dim rng1, rng2, cell1, cell2 As Range
' 4 ranges have been defined
Set rng1 = Worksheets("Sheet1").Range("C:C")
'rng1 defines the existing data in column B and worksheet1
Set rng2 = Worksheets("Sheet2").Range("C:C")
'rng2 defines the imported data in column D and worksheet2
For Each cell1 In rng1
If IsEmpty(cell1.Value) Then Exit For
'check for empty rows. If true then exit the program
For Each cell2 In rng2
If IsEmpty(cell2.Value) Then Exit For
If cell1.Value = cell2.Value Then
cell1.EntireRow.Interior.ColorIndex = cell2.EntireRow.Interior.ColorIndex
End If
'run the looping process
Next cell2
Next cell1
End Sub
Code is,
Sub findDuplicates()
' code to find duplicates in 2 different worksheets
Dim rng1, rng2, cell1, cell2 As Range
' 4 ranges have been defined
Set rng1 = Worksheets("Sheet1").Range("C:C")
'rng1 defines the existing data in column B and worksheet1
Set rng2 = Worksheets("Sheet2").Range("C:C")
'rng2 defines the imported data in column D and worksheet2
For Each cell1 In rng1
If IsEmpty(cell1.Value) Then Exit For
'check for empty rows. If true then exit the program
For Each cell2 In rng2
If IsEmpty(cell2.Value) Then Exit For
If cell1.Value = cell2.Value Then
cell1.EntireRow.Interior.ColorIndex = cell2.EntireRow.Interior.ColorIndex
End If
'run the looping process
Next cell2
Next cell1
End Sub