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

チェックボックスをExcelの複数のセルにリンクするにはどうすればよいですか?

チェックボックスを複数の相対セルにリンクすると、チェックされたセルまたはチェックされていないセルのみを合計、カウント、または平均化する必要がある場合に、すばやく簡単に計算を行うことができます。 しかし、ワークシートの複数のセルにチェックボックスを一度にリンクしようとしたことがありますか?

チェックボックスを数式を使用して複数のセルにXNUMXつずつリンクする

チェックボックスをVBAコードで一度に複数のセルにリンクする


矢印青い右バブル チェックボックスを数式を使用して複数のセルにXNUMXつずつリンクする

実際、チェックボックスを特定のセルにリンクするには、簡単な数式を適用して手動でリンクすることができます。

1。 ワークシートにチェックボックスを挿入した後、チェックボックスを選択するには、を押してください Ctrlキー キーを押してから、他のセルにリンクする最初のチェックボックスをクリックします。

2.次に、数式バーに等号を入力します =、次に、チェックボックスをリンクする2つのセル、たとえばBXNUMXをクリックします。スクリーンショットを参照してください。

doc-link-multiple-checkboxes-1

3。 そして、 入力します キーボードのキーを押すと、このチェックボックスをオンにすると、リンクされたセルが表示されます TRUE、チェックを外すと表示されます 間違った情報、スクリーンショットを参照してください:

doc-link-multiple-checkboxes-2

4。 上記の手順を繰り返して、他のチェックボックスをXNUMXつずつリンクします。


矢印青い右バブル チェックボックスをVBAコードで一度に複数のセルにリンクする

数百、数千のチェックボックスを他のセルにリンクする必要がある場合、最初の方法は効果的に機能しません。一度に複数のセルにリンクするには、次のVBAコードを適用できます。 このようにしてください:

1。 チェックボックスのリストを含むワークシートに移動します。

2。 を押し続けます Alt + F11 キーを押して Microsoft Visual Basic forApplicationsウィンドウ.

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

VBAコード:チェックボックスを一度に複数のセルにリンクする

Sub LinkChecks()
'Update by Extendoffice
Dim xCB
Dim xCChar
i = 2
xCChar = "B"
For Each xCB In ActiveSheet.CheckBoxes
If xCB.Value = 1 Then
    Cells(i, xCChar).Value = True
Else
    Cells(i, xCChar).Value = False
End If
xCB.LinkedCell = Cells(i, xCChar).Address
i = i + 1
Next xCB
End Sub

4。 そして、 F5 このコードを実行するためのキー。アクティブなワークシートのすべてのチェックボックスがセルにリンクされています。チェックボックスをオンにすると、その相対セルが表示されます。 TRUE、チェックボックスをオフにすると、リンクされたセルに表示されます 間違った情報、スクリーンショットを参照してください:

doc-link-multiple-checkboxes-3

Note:上記のコードでは、 I = 2、 人数、個数、総数 2 チェックボックスの開始行であり、文字 B チェックボックスをリンクする必要がある列の場所です。 必要に応じて変更できます。


関連記事:

ExcelでXNUMXつのチェックボックスを使用してすべてのチェックボックスを選択するにはどうすればよいですか?

Excelで複数のチェックボックスをすばやく挿入するにはどうすればよいですか?

Excelで複数のチェックボックスをすばやく削除するにはどうすればよいですか?

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

🤖 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 (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Will this work when I try to sort Alphabetically? I've found that when I sort from A-Z, the check boxes do not follow the cells they were originally next to. Will your method help? Thank you!
This comment was minimized by the moderator on the site
My problem is: I am creating a to do list with daily habits. I want to be able to make statistics from it using the true and false from checking the box linked to a cell but do not want to individually do it, but when i use the code nothing happens?
This comment was minimized by the moderator on the site
Hello, Gregor,
The VBA code works well in my workbook.
You can upload your file here, so that we can check where the problem is.
Thank you!
This comment was minimized by the moderator on the site
Здравствуйте.
Подскажите. Возможно ли суммирование чисел в ячейках по установке флажка?

https://drive.google.com/file/d/1qmEnngPDdgWTISJETJ44IkxG-MABfqhh/view?usp=sharing[/img][/b][/u][/b

В ячейке F3 скрыто число 2 а в ячейке G3 скрыто число 0,3, можно ли сделать так чтоб при установки галочки в ячейке Q3 вычислялась сумма.
Сумма вычислений только на строку в диапазоне F3-P3
This comment was minimized by the moderator on the site
great thread and it works for me.
BUT, I need to save the TRUE/FALSE data to another sheet. What is the VBA to save it to another sheet other than the active one?
This comment was minimized by the moderator on the site
How about if you have some empty rows in ColumnA (as per your example) in between checkboxes? Using the above code it gets the linked cells wrong if there are empty rows because it does not skip them. Interested to see the solution
This comment was minimized by the moderator on the site
Did u find any solution for this? Same problem
This comment was minimized by the moderator on the site
Sub LinkCheckBoxes()

Dim chk As CheckBox

Dim lCol As Long

lCol = 1 'number of columns to the right for link



For Each chk In ActiveSheet.CheckBoxes

With chk

.LinkedCell = _

.TopLeftCell.Offset(0, lCol).Address

End With

Next chk



End Sub
This comment was minimized by the moderator on the site
Hello! Nice post about the VBA... but what if there are 3 columns that has checkboxes that needs to be linked in three other columns as well? Let's say columns B, C, and D has checkboxes and should be linked to columns H, I, and J respectively.
This comment was minimized by the moderator on the site
Hi, Having same problem - Have you found out how to get around this? Thanks, Paul
This comment was minimized by the moderator on the site
Hey,

Try this:

Sub LinkCheckBoxes()
Dim chk As CheckBox
Dim lCol As Long
lCol = 2 'number of columns to the right for link

For Each chk In ActiveSheet.CheckBoxes
With chk
.LinkedCell = _
.TopLeftCell.Offset(0, lCol).Address
End With
Next chk

End Sub



If you have for example, checkboxes in D,E,F change "Icol" to 1, so it links to G,H and I, respectively.
This comment was minimized by the moderator on the site
Hi, I have the same issue but did not work for me, can you help please.Thanks
This comment was minimized by the moderator on the site
thank you very much
This comment was minimized by the moderator on the site
Can you help me out with this same problem?
This comment was minimized by the moderator on the site
Can I do this and program the boxes to say something other than true and false?
This comment was minimized by the moderator on the site
Hi, In your VBA code: link checkboxes to multiple cells at once, the code is set up to link the cell below it. How is the code if I want to link the cell to the left of the first one? Thanks!
This comment was minimized by the moderator on the site
i have more than 40000 cell which have checkbox. when i use this code, it takes more than 5 second to process, i define different macros for different cells but i have still the problem, what can i do?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations