VBA copy/ paste distinct values only, leave blanks and sort ascending

mariusnielsen

New Member
Joined
Mar 12, 2011
Messages
4
I'm fairly new to this and with some internet help I've managed to almost get it right, however would need my VBA to paste values only. I've tried with [FONT=&quot]Paste:=xlPasteValues without any luck. Anyone able to help me tweak this one a bit so it copies only values?

[/FONT]
Sub copytoHScode()

Sheets("Manifest").Activate


Range("J10", Cells(Rows.Count, "J").End(xlUp)).Copy


Sheets("Summary by hs code").Activate


Range("A17").Activate


Sheets("Summary by hs code").PasteSpecial


Application.Selection.RemoveDuplicates Columns:=1, Header:=xlNo


Range("A17").Select
Range("A17", Range("A17").End(xlDown)).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo


End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi & welcome to MrExcel.
How about
Code:
Sub mariusnielson()
   With Sheets("Manifest")
      .Range("J10", .Cells(Rows.Count, "J").End(xlUp)).Copy
   End With
   With Sheets("Summary by hs code")
      .Range("A17").PasteSpecial xlPasteValues
      .Range("A17", .Range("A" & Rows.Count).End(xlUp)).RemoveDuplicates 1, xlNo
      .Range("A17", .Range("A" & Rows.Count).End(xlUp)).Sort Key1:=.Range("A17"), Order1:=xlAscending, Header:=xlNo
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,178
Members
449,071
Latest member
cdnMech

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