sort question

  • Thread starter Thread starter carlos_ray86
  • Start date Start date
C

carlos_ray86

Quick question. I just realized that during my sort it goes from item
1 to item 10 then item 2 because its looking at just the digits not
the number as a whole. So is there a way to make it look at the whole
number my code is

With Sheets("Sheet1").Range("A1:E230")
.sort key1:=Sheets("Sheet1").Range("A1"), Order1:=xlAscending
End With

very simple!
 
Actually, your data isn't numeric--it's text.

If you format the cells as general and reenter the values (or convert them to
numbers some other way), you'll be able to sort ok.

One way to convert those text numbers to number numbers:
select an empty cell
edit|Copy
select A1:A230 (your range to fix)
edit|paste special|click Add
 
Ps.

Just to verify...

Try this in a couple of empty cells:

=count(A1:A230)
=counta(a1:a230)

The first counts numbers in that range.
The second counts all the non-empty cells (text or numbers).
 
Ps.

Just to verify...

Try this in a couple of empty cells:

=count(A1:A230)
=counta(a1:a230)

The first counts numbers in that range.
The second counts all the non-empty cells (text or numbers).










--

Dave Peterson- Hide quoted text -

- Show quoted text -

I am using both text and numbers and I need both. I tried doing the
pastespecial add function in the macros but it gave me an error. Is
there any other way to do this?
 
If you have a mixture of text and numbers:

1
11
11A
11B
12
13
2
2A
22B

You're going to have trouble. I think you have a couple of choices.

Put the numbers in one column and put the letters in the adjacent column and
sort the data using both those columns.

Or use Text for all the data and enter the data nicer:

00001
00011
00011A
00011B
00012
00013
00002
00002A
00022B


Maybe you don't need to convert the text numbers to number numbers at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top