How can i sort in seperate Sheet

Gaurav Walia

New Member
Joined
Aug 9, 2003
Messages
28
Delhi 5
Bangkok 15
Cairo 6
London 11
Singapore2

What I want is this should order in a separate excel sheet in the order listed below

Bangkok 15
London 11
Cairo 6
Delhi 5
Singapore2
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Sorry there might be duplicates also but i need only one result for delhi and bangkok sorted in order but the value will be same for delhi etc even if duplicates are there.
 
Upvote 0
Assuming data below is in sheet1 and you want it placed and then sorted in sheet2, try:
Code:
Sub MoveAndSort()
Dim i As Long
With Sheets("Sheet1")
    i = .Range("A" & Rows.Count).End(xlUp).Row
    .Range("A1:B" & i).Copy
End With
With Sheets("Sheet2").Range("A1")
    .PasteSpecial Paste:=xlValues
    .CurrentRegion.Sort Key1:=Range("B1"), Order1:=xlDescending
End With
End Sub
 
Upvote 0
My macro again but to remove duplicates and then sort:
Code:
Sub MoveAndSort()
Dim i As Long
With Sheets("Sheet1")
    i = .Range("A" & Rows.Count).End(xlUp).Row
    With .Range("A1:B" & i)
        .AdvancedFilter Action:=xlFilterInPlace, unique:=True
        .Copy
    End With
End With
With Sheets("Sheet2")
    .Range("A1").PasteSpecial Paste:=xlValues
    .Range("A1").CurrentRegion.Sort Key1:=Range("B1"), Order1:=xlDescending
End With
Sheets("Sheet1").ShowAllData
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

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