Reputation: 2300
I want to take columns from an excel worksheet and then sort them. Let say I have a column A with value a,b,c,d,e,f and another column B with value 3,5,6,1,5,6. I want to sort both columns A and B using the values of column B. I’m not sound in VBA. So I got stuck to get the two column and sort them out from excel sheet. Bubble sort is enough for me right now.
I wanna sort Column A and B using value of B
Upvotes: 0
Views: 1229
Reputation: 408
This should do it:
Range("A2:B10").Select
Selection.Sort Key1:=Range("B:B"), Order1:=xlAscending
To place sorted column A values in column C (leaving A undisturbed):
Range("C2:C10").Value = Range("A2:A10").Value
Range("B2:C10").Select
Selection.Sort Key1:=Range("B:B"), Order1:=xlAscending
Upvotes: 1