对字母数字值进行排序 [英] Sorting alphanumeric values
问题描述
大家好,
我有一个文件,我需要根据字母数据列对数据库提取进行排序。该列设置为文本以确保它不会在文本之前对数字进行排序,这很有效。
然而,当用户忽略输入1A为01A时会出现问题;
Excel按如下方式对文件进行排序:10A,10B,11C,19A,1A,20A,2A,MM10,MM11,MM1
代替所需:1A,2A ,10A,10B,11C,19A,20A,MM1,MM10,MM11。
如果用户输入01A而不是1A,它工作正常,但遗憾的是我没有这个控制权在它输入的系统中执行它。
有没有人知道这个问题的解决方案?
亲切的问候,
Oxydo
Hello everyone,
I have a file in which i need to sort a database extract based on an alphanummerical column. The column is set to text to ensure it doesnt sort numbers before text, which works well.
However, a problem arises when users ''neglect'' to input 1A as 01A;
Excel sorts my file as follows: 10A, 10B, 11C, 19A, 1A, 20A, 2A, MM10, MM11, MM1
In stead of the desired: 1A, 2A, 10A, 10B, 11C, 19A, 20A, MM1, MM10, MM11.
If the user inputs 01A in stead of 1A it works fine, but sadly i dont have this control to enforce it in the system it''s input into.
Does anyone know a solution to this problem?
Kind regards,
Oxydo
推荐答案
将0字符添加到缺少它的字符。
Prepend the 0 character to the ones that are missing it.
@Rabbit
你好,兔子,
我一直在想同样的路线。但是,我如何把它放在公式中?如果我只是将0添加到它不会工作的一切,并且可能性(搜索和替换或交叉表)的数量是惊人的(1A到1ZZZ)。
我的另一种选择是更改排序顺序(这是可能的)从0123456789abcdef ..到abcdef0123456789。
祝你好运,
Oxydo
@Rabbit
Hi Rabbit,
I was thinking along the same lines. However, how do i put this in a formula? If i just add an 0 to everything it wont work, and the amount of possibilities (to search and replace or crosstab) is staggering (1A to 1ZZZ).
My other option would be to change the sortorder (is this possible) from 0123456789abcdef.. to abcdef0123456789.
Best regards,
Oxydo
你不能改变那样的排序顺序。但你可以抓住前两个字符,检查它是否是数字,如果不是,那就意味着它缺少0个字符,然后在它前面添加。
You can''t change the sort order like that. But you can grab the first two characters, check if it''s numeric, if it''s not, that means it''s missing the 0 character, and then prepend it.
这篇关于对字母数字值进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!