Excel Formula to Generate Unique Sorted List

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,549
Office Version
  1. 2016
Platform
  1. Windows
Dear All,

Hope you all are doing well
Please have a look at the sheet & let me know whether is it possible to achieve with formulas (I am using excel 2016)

The purpose is to have Unique Sorted Values in ascending order → By Column B, then by Column A, then By Column C with custom sort list as Set(s), Pc(s), Pair(s) & Dozen(s)

Book1
ABC
1ARTICLEQUALITYUNIT
2BlanketPolyester 125 GSMDozen(s)
3BlanketPolyester 125 GSMDozen(s)
4BlanketPolyester 125 GSMSet(s)
5BlanketPolyester 125 GSMSet(s)
6BlanketPolyester 125 GSMPc(s)
7Fitted SheetCVC 90 GSMPair(s)
8Fitted SheetCVC 90 GSMPair(s)
9Fitted SheetCVC 90 GSMSet(s)
10Fitted SheetCVC 90 GSMPc(s)
11
12
13DESIRED RESULT ↓
14ARTICLEQUALITYUNIT
15Fitted SheetCVC 90 GSMSet(s)
16Fitted SheetCVC 90 GSMPc(s)
17Fitted SheetCVC 90 GSMPair(s)
18BlanketPolyester 125 GSMSet(s)
19BlanketPolyester 125 GSMPc(s)
20BlanketPolyester 125 GSMDozen(s)
Sheet3


Regards,

Humayun
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
With Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Duplicates" = Table.Distinct(Source)
in
    #"Removed Duplicates"
 
Upvote 0
Thanks for the reply but I need an excel formula (If possible)
 
Upvote 0
Dear All,

It seems like it is not possible to achieve with a formula...

so, can anybody please provide a vba code pls ?

Regards,

Humayun
 
Upvote 0
Try.
VBA Code:
Sub SortRemoveDuplicates()
With Range("A1").CurrentRegion
.Sort Key1:=Range("A2"), Order1:=xlDescending, Key2:=Range("B2"), Order2:=xlDescending, Key3:=Range("C2"), Order3:=xlDescending, Header:=xlYes
.RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
End With
End Sub
 
Upvote 0
Try.
VBA Code:
Sub SortRemoveDuplicates()
With Range("A1").CurrentRegion
.Sort Key1:=Range("A2"), Order1:=xlDescending, Key2:=Range("B2"), Order2:=xlDescending, Key3:=Range("C2"), Order3:=xlDescending, Header:=xlYes
.RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
End With
End Sub
Hello @kvsrinivasamurthy

Thanks for the reply but the code you provided just removes the duplicates and that too on the actual data. whereas I want a separate list to be generated starting cell A15 with the actual data remaining as it is... Can you pls go through the mini sheet I posted in my initial post
 
Upvote 0
Like this?

VBA Code:
Sub New_List()
  With Range("A" & Rows.Count).End(xlUp).Offset(4).Resize(Range("A" & Rows.Count).End(xlUp).Row, 3)
    .Value = Range("A1").CurrentRegion.Value
    .Sort Key1:=.Columns(2), Order1:=xlAscending, Key2:=.Columns(1), Order2:=xlAscending, Key3:=.Columns(3), Order3:=xlDescending, Header:=xlYes
    .RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
  End With
End Sub
 
Upvote 0
Hello @kvsrinivasamurthy

Thanks for the reply but the code you provided just removes the duplicates and that too on the actual data. whereas I want a separate list to be generated starting cell A15 with the actual data remaining as it is... Can you pls go through the mini sheet I posted in my initial post
Or this.

VBA Code:
Sub SortRemoveDuplicates()
Dim lngStart As Long
Dim Ws As Worksheet

    Set Ws = ActiveSheet
    
    lngStart = Ws.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row + 5
    
    Ws.Range("A1").CurrentRegion.Copy Ws.Range("A" & lngStart)
    
    With Ws.Range("A" & lngStart).CurrentRegion
        
        .Sort Key1:=Range("A" & lngStart), Order1:=xlDescending, _
            Key2:=Range("B" & lngStart), Order2:=xlDescending, _
            Key3:=Range("C" & lngStart), Order3:=xlDescending, Header:=xlYes
    
        .RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
    
    End With

End Sub
 
Upvote 0
Like this?

VBA Code:
Sub New_List()
  With Range("A" & Rows.Count).End(xlUp).Offset(4).Resize(Range("A" & Rows.Count).End(xlUp).Row, 3)
    .Value = Range("A1").CurrentRegion.Value
    .Sort Key1:=.Columns(2), Order1:=xlAscending, Key2:=.Columns(1), Order2:=xlAscending, Key3:=.Columns(3), Order3:=xlDescending, Header:=xlYes
    .RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
  End With
End Sub
Hi Peter,

Thanks for the reply

Is it possible to generate the list on some other sheet which is within the workbook → sheet name "Supplier Wise" starting from B11
& instead of looking at the Column A for Article, Column B for Quality & Column for Units it should look at the named ranges as "orders_article", "orders_quality" & "orders_unit"

Further, please note that the data I provided was a sample data but the actual data is very huge & I have noticed that the whole data is being copied and then the duplicates are been removed. I don't want this to happen as there is a lot of other things going on at the bottom of the sheet where I want the list to be generated..

Regards,

Humayun
 
Upvote 0
Try.
VBA Code:
Sub SortRemoveDuplicates()
With Range("A15")
.CurrentRegion.Clear
Range("A1").CurrentRegion.Copy Range("A15")
.CurrentRegion.Sort Key1:=.Offset(1, 0), Order1:=xlDescending, Key2:=.Offset(1, 1), Order2:=xlDescending, Key3:=.Offset(1, 2), Order3:=xlDescending, Header:=xlYes
.CurrentRegion.RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,491
Messages
6,185,298
Members
453,286
Latest member
JCM

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