在CHAR中跳过字母O,I,Z(RANDBETWEEN(65,90))

时间:2017-03-15 13:24:14

标签: excel excel-formula

我正在尝试以excel中22AA22 (Number+Number+Alphabet+Alphabet+Number+Number)的格式生成6位数的随机数(100,000个随机数)。

Number = 2 to 9 Excluding 0 and 1
Alphabet (in CAPS) = A to Y Excluding O, I, Z

我正在使用

=RANDBETWEEN(2,9)&RANDBETWEEN(2,9)&CHAR(RANDBETWEEN(65,90))&CHAR(RANDBETWEEN(65,90))&RANDBETWEEN(2,9)&RANDBETWEEN(2,9)

CHAR(RANDBETWEEN(65,90))中如何跳过字母O,I,Z(包括低级和大写)。

2 个答案:

答案 0 :(得分:2)

将RANDBETWEEN拆分为三个并将CHOOSE与另一个RANDBETWEEN一起使用:

CHAR(CHOOSE(RANDBETWEEN(1,3),RANDBETWEEN(65,72),RANDBETWEEN(74,78),RANDBETWEEN(80,89)))

这样:

=RANDBETWEEN(2,9)&RANDBETWEEN(2,9)&CHAR(CHOOSE(RANDBETWEEN(1,3),RANDBETWEEN(65,72),RANDBETWEEN(74,78),RANDBETWEEN(80,89)))&CHAR(CHOOSE(RANDBETWEEN(1,3),RANDBETWEEN(65,72),RANDBETWEEN(74,78),RANDBETWEEN(80,89)))&RANDBETWEEN(2,9)&RANDBETWEEN(2,9)

答案 1 :(得分:2)

或者 - 对于Scott Craner的解决方案 - 你也可以列出可用的选项,然后从列表中获得一个随机数:

=CHAR(INDEX({65,66,67,68,69,70,71,72,74,75,76,77,78,80,81,82,83,84,85,86,87,88,89},RANDBETWEEN(1,23)))