A N M Bazlur Rahman
A N M Bazlur Rahman

Reputation: 2300

Help needed on sorting excel column value

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.

enter image description here

I wanna sort Column A and B using value of B

Upvotes: 0

Views: 1229

Answers (1)

America
America

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

Related Questions