特定の文字列から文字を組み替えてランダムな文字列を作り直す、Excelでアナグラムを自動生成する方法です。
成果物

このように、元の文字列を組み替えた文字列を自動生成する状態を目指します。
アナグラムの生成
文字の抽出

C1にアナグラムしたい文字列を置きます。日本語でも英語でも数字でもOKです。

C2セルに
=Mid($C$1,Row()-1,1)
と記述し、
これを下のほうまでオートフィルで伸ばします。元の文字数を超えた部分は何も表示されません。
乱数の生成

A2セルには
=If(C2 ="","",Rand())
と記述し、文字を組み替えるための乱数を発生させます。
同様に下のほうまで伸ばします。
乱数を順序化

さらにB2セルも
=IfError(Rank.Eq(A2,A:A),"")
と入力して、
やはり下のほうへと伸ばします。
抽出した文字の組み替え

D2セルに
=IfError(VlookUp(Row()-1,B:C,2,FALSE),"")
と入力し、
例によって伸ばします。
文字列の結合(完成)

最後にアナグラムを出力したいセルに
=Concat(D2:D1000)
と入力してEnterを押します(数字は適当です)。
文字列内の文字がランダムに並び替えされます。
F9を押すたびに再計算が入りアナグラムが変わります。
F9を押すたびに再計算が入りアナグラムが変わります。

気に入ったものがあったら、値をコピーしてただの文字列に変換しておきます。
アナグラムする文字列の変更

C1の文字列を変更すれば、出力されるアナグラムも変更されます。

もし長い文字列がうまく変換できない場合は、

A~D列が足りてないので、オートフィルで下に延長してあげてください。
別の方法、関連記事
使っている関数はこの記事とほぼ同一なので、解説は省略します。
何回も並べ替えしないなら、一文字ずつ抽出して並べ替えしたものを結合するほうが簡単です。

Excel(エクセル):ランダム、乱数
Excelの乱数、ランダム関連操作、関数等まとめです。
乱数の作成
関数で乱数を求める場合、Rand関数(0~1の乱数)またはRandBetween関数(指定範囲の整数)を用います。
もしビンゴで使うような重複...
コメント