22
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Excelでユニークでランダムな8桁の文字列を生成するやつ

Last updated at Posted at 2018-07-31

Excelでサンプルデータなどで利用するために、ユニークでランダムな8桁の文字列を大量に作りたいときのコード

前提:keyというシートを作ってA1に
abcdefghijklmnopqrstuvwxyz0123456789
という文字列が入っている

以下を1つのセルに丸ごとコピペしていれてフィルハンドルを引っ張って必要な分をいれる。


=CONCATENATE(MID(key!$A$1,(RANDBETWEEN(1,LEN(key!$A$1))),1),MID(key!$A$1,(RANDBETWEEN(1,LEN(key!$A$1))),1),MID(key!$A$1,(RANDBETWEEN(1,LEN(key!$A$1))),1),MID(key!$A$1,(RANDBETWEEN(1,LEN(key!$A$1))),1),MID(key!$A$1,(RANDBETWEEN(1,LEN(key!$A$1))),1),LOWER(BASE(ROW(),36,3)))


中身は生成されるものはランダムな文字列5桁+行番号の36進数でユニークを担保している。
桁数は8桁だが改造したら何桁でもできる。

以下に実際に生成された20個を参考として記載。

d88ik001
72wyc002
xr7b2003
ra2d4004
th467005
gseyh006
mgfyp007
mj74u008
vsfc8009
ut3u500a
d5wj600b
b8dkp00c
kyta200d
hz2pg00e
s9vxe00f
xquu300g
ug36i00h
872sw00i
r4h9400j
yfyut00k

22
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?