Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i need to sort one of my excel worksheet columns with value like this:

cell values
1-7-1
1-2-1
1-14-1
1-1-1
1-1-2
2-1-2

and i like see that afther sort like this
1-1-1
1-2-1
1-7-1
1-14-1
1-1-2
2-1-2
i need vba macro to provide that
Posted
Comments
Sandeep Mewara 13-May-12 15:23pm    
Ok. And where are you stuck? Tried anything? Please update the question with details.

1 solution

Just record macro!

Let's say, your data are in column A.
1) Start recording
2) Select column A
3) Menu Data->Text As Columns
4) Menu Data->Sort (by column A, B, C)
5) For cell D1 add formula =A1 & "-" & B1 & "-" & C1
6) Fill down the formula
7) Stop recording
8) ALT+F11 to open "VBA Code Editor" window

That's all!
 
Share this answer
 
Comments
Sandeep Mewara 14-May-12 4:56am    
Good. 5!
Maciej Los 14-May-12 7:13am    
Thank you, Sandeep ;)
Wendelius 14-May-12 17:10pm    
That should resolve the problem. 5
Maciej Los 14-May-12 17:11pm    
Thank you, Mika ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900