Copy, Paste and remove duplicates

gemini528

Board Regular
Joined
Jun 13, 2013
Messages
53
I have two sheets on Excel and I need help for a VBA code tocopy the data from the DATA sheet to the DEDUP sheet, removed duplicate andsorted. Macro is triggered when DEDUP sheet is activated.<o:p></o:p>
<o:p> </o:p>
Sheet 1 named “DATA” and it has the data starting from column F8, (F7 is the heading)<o:p></o:p>
Sheet 2 names “DEDUP”, in this sheet the dedup and sorteddata will be copied starting at N12, (N11 is the heading)<o:p></o:p>
<o:p> </o:p>
I need help guys. Thanks a lot in advance.<o:p></o:p>
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi try the below code, amend ranges as required:

Sub test()'
' test Macro
'


'
Sheets("DEDUP").Select
Range("N12:N1000").Select
Selection.ClearContents
Sheets("DATA").Select
Range("F8:F1000").Select
Selection.Copy
Sheets("DEDUP").Select
Range("N12").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Range("$N$11:$N$1000").RemoveDuplicates Columns:=1, Header:=xlYes

End Sub

Not too sure about it running when the sheet is activated but you can Google it and find it.

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,122
Members
452,545
Latest member
boybenqn

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