Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Macro: sorting by specific words in cells in Excel

$
0
0

Hello Excel experts!

I have a question regarding Excel macro.  At my laboratory we generate an awful lot of data in asc files, which we import into Excel spreadsheets using pre-existing macro.  However, once the data is imported into the spreadsheets, we need to be able to sort these data in quite a specific way.  So for example, the first column of workbook will have sample numbers in the form of:

 

Row 1: P1021_M0023_IP13013_S1384@2

Row 2: P1021_M0023_IP13013_S1384@3

Row 3: P1021_M0023_IP13013_S1384@1

Row 4: P1021_M0023_IP13013_FM2L2_S1384@4

Row 5: P1021_M0023_IP13013_FM2L2_S1386@2

Row 6: P1021_M0023_IP13013_S1385@2

Row 7: P1021_M0023_IP13013_S1385@1

Row 8: P1021_M0023_IP13013_S1386@1

But we need these sorted in the order of the very last value, "S1384@1", "S1384@2", etc. so that they look like this after sorting even with the different prefixes before the "S1384@1" numbers:

Row 1: P1021_M0023_IP13013_S1384@1

Row 2: P1021_M0023_IP13013_S1384@2

Row 3: P1021_M0023_IP13013_S1384@3

Row 4: P1021_M0023_IP13013_FM2L2_S1384@4

Row 5: P1021_M0023_IP13013_S1385@1

Row 6: P1021_M0023_IP13013_S1385@2

Row 7: P1021_M0023_IP13013_S1386@1

Row 8: P1021_M0023_IP13013_FM2L2_S1386@2

Is there a way of writing a macro for this type of sorting?  It's not a straight forward sorting of the cell as sorting - sometimes these sample names have different prefixes 

I'd really appreciate any help!

Thanks very much.

Anna




Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>