メインコンテンツへスキップ

Excelで宝くじ番号を生成する方法は?

Excelで宝くじ番号を生成したり、Excelで自分で宝くじ番号ジェネレーターを作成したりすることを考えたことはありますか? この記事では、それを簡単に行うためのXNUMXつの方法を紹介します。


Excel関数で宝くじ番号を生成する

この方法では、いくつかのExcel関数を適用して宝くじ番号を生成する手順を説明します。 そして、あなたは次のようにすることができます:

1。 空白のワークシートに、以下のスクリーンショットに示すように、範囲A1:C1に列ヘッダーを入力します。

2。 列A、列B、および列Cに数式を入力します。

(1)セルA2に、数式を入力します = RAND()、次に、塗りつぶしハンドルをA2:A50の範囲にドラッグします。
(2)セルB2に、数式を入力します =RANK($A2,$A$2:$A$50)+COUNTIF(B$1:B1,B1)-1、次にフィルハンドルを範囲B2:B50にドラッグします。 (数式では、A2は現在のセルに残された乱数、$ A $ 2:$ A $ 50はすべて最初の数式で取得した乱数、B $ 1は列Bの最初のセル、B1は現在のセルより上のセルです。細胞)。
(3)範囲C2:C50に、1から49までのシーケンス番号を入力します。

次に、左のスクリーンショットが示すようにテーブルを取得します。

 

ノートリボン 数式は複雑すぎて覚えられませんか? 数式を定型句として保存して、後でワンクリックで再利用できるようにします。
続きを読む...     無料体験

3。 以下のスクリーンショットに示すように、空白の範囲を見つけて、シーケンス番号を水平方向に続けて入力します。

4。 最初のシーケンス番号1の下に、式を入力します = VLOOKUP(G1、$ B $ 1:$ C $ 50,2、FALSE) その中に、フィルハンドルを必要な範囲にドラッグします。

Note:この数式では、G1は最初のシーケンス番号が1のセルで、$ B $ 1:$ C $ 50は一意のランク列とボール番号列です。2は、範囲$ B $ 1:$ C $ 50のXNUMX番目の列で値を見つけることを意味します。 。

次に、以下のスクリーンショットに示すように宝くじ番号を取得します。

5。 これはオプションです。 現在のワークシートが更新されたときに宝くじ番号が自動的に変更されないようにするには、 > 計算オプション > マニュアル.

Excelでいくつかの一連のデータのすべての組み合わせを簡単に一覧表示します

Excel用のKutools すべての組み合わせを一覧表示 ユーティリティは、いくつかの特定の一連のデータから可能なすべての組み合わせを一般化するように設計されており、以下のスクリーンショットに示すように、これらの組み合わせを列にリストします。


すべての組み合わせのリストとして1

Kutools for Excel - 300 以上の必須ツールで Excel を強化します。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 今すぐ入手

VBAマクロで宝くじ番号を生成する

この方法では、VBAマクロを適用してExcelで宝くじ番号を生成する方法を説明します。 次のようにしてください。

1。 押す 他の + F11 キーを押して、Microsoft Visual Basic forApplicationsウィンドウを開きます。

2に設定します。 OK をクリックします。 インセット > モジュール 新しいモジュールウィンドウを開き、次のVBAコードを貼り付けます。

VBA:Excelの宝くじ番号ジェネレーター

Sub LotteyCode()
Dim Rng As Range
Dim WorkRng As Range
Dim xNumbers(49) As Integer
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Out put to (single cell):", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.Range("A1")
For xIndex = 1 To 49
xNumbers(xIndex) = xIndex
Next
For xIndex = 1 To 6
xNum = 1 + Application.Round(Rnd * (49 - xIndex), 0)
WorkRng.Offset(0, xIndex - 1).Value = xNumbers(xNum)
xNumbers(xNum) = xNumbers(50 - xIndex)
Next
End Sub

3。 プレス F5 キーを押すか、 ラン このVBAマクロを実行するためのボタン。

4。 ポップアップダイアログボックスで、宝くじ番号を出力するセルを指定し、[ OK

次に、6つの一意の宝くじ番号が生成され、指定されたセルに表示されます。


Kutools forExcelで宝くじ番号を生成する

Kutools for Excelがインストールされている場合、 ランダムデータを挿入 ユーティリティは、Excelで宝くじ番号を一度に生成するのに役立ちます。

Kutools for Excel - Excel に必要な 300 以上のツールが詰め込まれています。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 ダウンロード中!

1。 A6:F1などの1つの隣接するセルを選択し、[ クツール > インセット > ランダムデータを挿入.

2。 これで、[ランダムデータの挿入]ダイアログボックスが表示されます。 に移動します 整数 タブ、タイプ 1 in ボックス、タイプ 49 in ボックス、チェックボックス 一意の値 オプションをクリックし、 OK ボタン。 これで、6つの一意の宝くじ番号が生成され、選択したセルにすぐに表示されます。

Kutools for Excel - 300 以上の必須ツールで Excel を強化します。 クレジット カードは必要なく、全機能を備えた 30 日間の無料トライアルをお楽しみください。 今すぐ入手


デモ:Kutools forExcelで宝くじ番号を生成する


Kutools for Excel: 300 を超える便利なツールをすぐに利用できます。 機能制限なしの 30 日間の無料トライアルを今すぐ始めてください。 今すぐダウンロード!

関連記事:

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (15)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
the system dont work ,what is wrong i have inserted all the formular
This comment was minimized by the moderator on the site
The file does not work with the fromula ,what is wronG

please let me know

i copy the formular all is correct .
This comment was minimized by the moderator on the site
Hi there,

Could you please attach the file you are working?

Amanda
This comment was minimized by the moderator on the site
Thank you Amanda for your assistance.
This comment was minimized by the moderator on the site
Yes 25 numbers from 1 to 49.
I have tried using the same formula but once a number bigger than 25 is picked the next number in the sequence cannot be shown and error occurs.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi I have tried the Vlookup way that you shown here it works great and it is easy to generate the numbers for the 1 to 49 range.

But I was thinking of eliminating some numbers in play like for example instead of running numbers I will have 25 numbers from 1 to 49. How will I need to adjust the Vlookup formula to make it work?
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi Yogi, sorry I don't quite understand your request. What do you mean by having 25 numbers from 1 to 49?
This comment was minimized by the moderator on the site
What is the purpose of COUNTIF(B$1:B1,B1)-1 in the formula in step B?
This comment was minimized by the moderator on the site
Hi hyungsup kim,
COUNTIF(B$1:B1,B1)-1 will prevent duplicates in the Column B. For example, if the B1 is a unique value, this part will return 0 which won’t affect the ranking result; if the B1 is duplicate, this part will adjust the ranking result slightly.
This comment was minimized by the moderator on the site
calculate the next day lottery number for kerala lottery - india
This comment was minimized by the moderator on the site
calculate the next day guess for kerala lottery
This comment was minimized by the moderator on the site
hay, Santhanam did you every win with this program?
This comment was minimized by the moderator on the site
: I would like to try your new programs see how the numbers predict
This comment was minimized by the moderator on the site
I will like to win some luck number
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations