Sorting two columns of data

  • Thread starter Thread starter Nick Holway
  • Start date Start date
N

Nick Holway

Hi,

I'm trying to write a script in VBA to sort two columns of data. The data
source cannot be changed as it is the order of genes we have printed on an
array. I want to have the gene names in order then a dilution factor like
this:

gene 1 1
gene1 2
gene1 4
gene2 1
gene2 2
etc

In the left hand column I have names such as gene1 and then a dilution eg
32x which looks like "gene1 32x". I've pulled out the number out of the name
and put it in column two and then deleted it in column 1. I then tried to
record a sort using the macro recorder, sorted column A, then by B. The
problem is that when there are two digits ie 16 or 32 they don't sort in the
right order compared to the single digit numbers.

Has any one any idea how to sort this out (sorry about the pun :-)).

If it's any help I'm using Excel 2002 on Windows XP Pro.

TIA

Nick Holway
 
If your column is populated with numbers, then it will sort 1,2,10,20.
If your column is populated with numeric text, then it will sort
1,10,2,20.

If you have numeric text and you want to convert to numbers, then select
the column, then Data > Text to Columns. Then click Finish. Now sort.

If you have numbers that you want to convert to numeric text, then
select the column, Data > Text to Columns, Next, Next. You should be at
step 3 of the Wizard (this is Excel97) where you can specify your data
type -- choose Text and click Finish. Now sort.

If you've got a different version of Excel, I don't know what the exact
steps might be, but you should be able to do something similar.

--
Dianne


In Nick Holway <nickATholwayDOTeclipseDOTcoDOTuk (Replace capitals with
symbols)> typed:
 
Back
Top