PDA

View Full Version : Sort with Multiple columns using VBA



srinivasan05
01-02-2012, 09:58 AM
Hi

I need to sort the data in excel using three columns.The data has to be sorted first by columnA and then by columnB in ascending order and then by Column C.IN ColumnC the first three characters has to be taken into consideration.Suppose we have ABC01 and AB001.Then the third character with the alphabet ie ABC01 should be placed ahead of AB001.

Am able to sort the by coulumnA and ColumnB by Sorting them by ColumnC is bit confusing.
Any ideas for that.





ColumnA ColumnB ColumnC
A 190 ABC01
C 180 AB021
C 180 ABC01
B 180 AD236
E 180 AV002


The output should be



ColumnA ColumnB ColumnC
A 190 ABC01
B 180 AD236
C 180 ABC01
C 180 AB021
E 180 AV002

mdmackillop
01-02-2012, 01:14 PM
Welcome to VBAX
You can post a sample workbook using Manage Attachments in the Go Advanced reply section.
It looks as though you may need to created a "Helper" column in the format xxx### to allow sorting on consistent data.

srinivasan05
01-03-2012, 02:55 AM
Hi mdmackillop

Thanks for the warm welcome.

I have attached a sample Excel consisting input table and the output table that i need.

Please let me know for further information

Thanks
Srini

mdmackillop
01-03-2012, 05:13 AM
Something like the attached, sort on columns A-C

srinivasan05
01-03-2012, 07:44 AM
Hi mdmackillop

Thanks you.yeah that almost what i need. Can the process be made using excel vba code for a column.

Thanks
Srini