View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
eliano[_2_] eliano[_2_] is offline
external usenet poster
 
Posts: 79
Default Copy and Sort Unique

On 13 Ago, 23:24, cranen wrote:
I have a list of item numbers in column “C” on Sheet 1. *There are multiple
item numbers that are the same. *In fact, the first two and sometimes more
are the exact same item number. *My Summary Sheet (Sheet 2) is used to
calculate a quantity using a SUMIF statement dependent on the item number.. *
Well, I tried using a macro to copy and sort the unique values from column
“C” on sheet 1 to my Summary Sheet, but it continues to copy the top two
values which are the exact same. *When this happens, it is messing up my
summary sheet. *What is the best way to fix this? *I appreciate your help. *
Thanks.


Hi cranen.
I dont know what is the best way, but try:

Public Sub prova()
Dim x As Long, y As Long
Sheets(1).Select
y = Range("C1").End(xlDown).Row
Range("C1").FormulaLabel = xlColumnLabels
Range("C1:C" & y & "").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Sheets(2).Range("A1"), Unique:=True
Sheets(2).Select
x = Range("A1").End(xlDown).Row
Range("A1:A" & x & "").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
Range("A1").Select
End Sub

Change with your references and let us know.
Regards
Eliano