(MS Excel 10) Copy from 1 Sheet to another?

Lovelylou79

New Member
Joined
Sep 4, 2017
Messages
37
Hi There Forum,

I have pilfered a great code that finds duplicates on two sheets and highlights the duplicates on the newest sheet.

I'd like to add a function that will copy the data from rng1 "K" and paste into rng2 "K" as well as highlighting.

I've tried manipulating the code myself, but I can't seem to get it right.

This is the code I'm using;

Dim lastrow As Integer
lastrow = FindLastRow

Range("L2:L" & lastrow).Formula = "=A2 & F2 & G2 & H2"

Sheets("ps").Activate
Range("L2:L" & lastrow).Formula = "=A2 & F2 & G2 & H2"

'Checks for dupliactes
Dim cell As Range, cella As Range, rng As Range, srng As Range

Set rng1 = Sheets(ComboBox1.Value).Range("L2:L" & lastrow)
Set rng2 = Sheets("ps").Range("L2:L" & lastrow)

For Each cell In rng1
For Each cella In rng2
If cella = cell Then
cella.EntireRow.Interior.ColorIndex = 15
End If
Next cella
Next cell

'Clears Concatenated data after function
Sheets(ComboBox1.Value).Range("L2:L" & lastrow).ClearContents
Sheets("ps").Range("L2:L" & lastrow).ClearContents


Thanks in advance!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try this :

Code:
If cella = cell Then
    cella.EntireRow.Interior.ColorIndex = 15
[COLOR=#ff0000]    cella(1, 0).Value = cell(1, 0)[/COLOR]
End If
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,051
Members
452,542
Latest member
Bricklin

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