ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copy and Sort Unique (https://www.excelbanter.com/excel-discussion-misc-queries/239690-copy-sort-unique.html)

cranen

Copy and Sort Unique
 
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.

eliano[_2_]

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

cranen

Copy and Sort Unique
 
I tried plugging in my references, and I didn't have any luck. I might have
confused you with my previous request. All I need is a macro that copies and
sorts unique values from one column to a column in another worksheet without
copying the second value if it is the same as the first value. Thanks for
your help.

"eliano" wrote:

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



All times are GMT +1. The time now is 08:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com