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

Excelのチェックボックスでセルまたは行を強調表示するにはどうすればよいですか?

以下のスクリーンショットに示すように、チェックボックスで行またはセルを強調表示する必要があります。 チェックボックスをオンにすると、指定した行またはセルが自動的に強調表示されます。 しかし、Excelでそれを達成する方法は? この記事では、それを実現するためのXNUMXつの方法を紹介します。

条件付き書式のチェックボックスでセルまたは行を強調表示する
VBAコードのチェックボックスでセルまたは行を強調表示します


条件付き書式のチェックボックスでセルまたは行を強調表示する

条件付き書式ルールを作成して、Excelのチェックボックスでセルまたは行を強調表示できます。 次のようにしてください。

すべてのチェックボックスを指定されたセルにリンクする

1.クリックして手動でセルにチェックボックスをXNUMXつずつ挿入する必要があります Developer > インセット > チェックボックス (フォームコントロール).

2.これで、列Iのセルにチェックボックスが挿入されました。I1の最初のチェックボックスを選択して、数式を入力してください = $ J1 数式バーに入力し、を押します 入力します キー。

先端:隣接するセルの値をチェックボックスに関連付けたくない場合は、チェックボックスを次のような別のワークシートのセルにリンクできます。 = Sheet3!$ E1.

2.すべてのチェックボックスが隣接するセルまたは別のワークシートのセルにリンクされるまで、手順1を繰り返します。
Note:リンクされたすべてのセルは連続していて、同じ列に配置されている必要があります。

条件付き書式ルールを作成する

次に、次の手順に従って条件付き書式ルールを作成する必要があります。

1.チェックボックスで強調表示する必要のある行を選択し、をクリックします 条件付き書式 > 新しいルールホーム タブ。 スクリーンショットを参照してください:

2。 の中に 新しい書式設定規則 ダイアログボックスでは、次のことを行う必要があります。

2.1を選択します 式を使用して、フォーマットするセルを決定する 内のオプション ルールタイプを選択します ボックス;

2.2数式を入力する = IF($ J1 = TRUE、TRUE、FALSE) この数式が真であるときの書式値 ボックス;
      Or = IF(Sheet3!$ E1 = TRUE、TRUE、FALSE) チェックボックスが別のワークシートにリンクされている場合。

2.3 フォーマット 行の強調表示された色を指定するボタン。

2.4 OK ボタン。 スクリーンショットを参照してください:

Note:式では、 $ J1 or $ E1 チェックボックスの最初のリンクされたセルであり、セル参照が列絶対に変更されていることを確認します(J1> $ J1 or E1> $ E1).

これで、条件付き書式ルールが作成されました。 チェックボックスをオンにすると、以下のスクリーンショットに示すように、対応する行が自動的に強調表示されます。


VBAコードのチェックボックスでセルまたは行を強調表示します

次のVBAコードは、Excelのチェックボックスでセルまたは行を強調表示するのにも役立ちます。 次のようにしてください。

1.ワークシートで、チェックボックスを使用してセルまたは行を強調表示する必要があります。 右クリック シートタブ をクリックして コードを表示 右クリックメニューから アプリケーション向け Microsoft Visual Basic 窓。

2.次に、以下のVBAコードをコピーして[コード]ウィンドウに貼り付けます。

VBAコード:Excelのチェックボックスで行を強調表示する

Sub AddCheckBox()
Dim xCell As Range
Dim xRng As Range
Dim I As Integer
Dim xChk As CheckBox
On Error Resume Next
InputC:
    Set xRng = Application.InputBox("Please select the column range to insert checkboxes:", "Kutools for Excel", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
If xRng.Columns.Count > 1 Then
    MsgBox "The selected range should be a single column", vbInformation, "Kutools fro Excel"
    GoTo InputC
Else
    If xRng.Columns.Count = 1 Then
        For Each xCell In xRng        
            With ActiveSheet.CheckBoxes.Add(xCell.Left, _
               xCell.Top, xCell.Width = 15, xCell.Height = 12)
               .LinkedCell = xCell.Offset(, 1).Address(External:=False)
               .Interior.ColorIndex = xlNone
               .Caption = ""
               .Name = "Check Box " & xCell.Row
            End With    
            xRng.Rows(xCell.Row).Interior.ColorIndex = xlNone                  
        Next        
    End If    
    With xRng    
     .Rows.RowHeight = 16    
    End With   
    xRng.ColumnWidth = 5#    
    xRng.Cells(1, 1).Offset(0, 1).Select    
    For Each xChk In ActiveSheet.CheckBoxes   
      xChk.OnAction = ActiveSheet.Name + ".InsertBgColor"      
    Next
End If
End Sub

Sub InsertBgColor()
Dim xName As Integer
Dim xChk As CheckBox
For Each xChk In ActiveSheet.CheckBoxes 
  xName = Right(xChk.Name, Len(xChk.Name) - 10) 
  If (xName = Range(xChk.LinkedCell).Row) Then   
   If (Range(xChk.LinkedCell) = "True") Then   
    Range("A" & xName, Range(xChk.LinkedCell).Offset(0, -2)).Interior.ColorIndex = 6    
   Else    
    Range("A" & xName, Range(xChk.LinkedCell).Offset(0, -2)).Interior.ColorIndex = xlNone  
   End If  
  End If
Next
End Sub

3。 プレス F5 コードを実行するためのキー。 ((Note:F5キーを適用するには、コードの最初の部分にカーソルを置く必要があります)ポップアップで Kutools for Excel ダイアログボックスで、挿入する範囲のチェックボックスを選択し、[ OK ボタン。 ここでは、範囲I1:I6を選択します。 スクリーンショットを参照してください:

4.次に、選択したセルにチェックボックスが挿入されます。 チェックボックスのいずれかをチェックすると、下のスクリーンショットに示すように、対応する行が自動的に強調表示されます。


関連記事:

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

🤖 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 (3)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This is a horrendous article. It lacks a lot of information and steps. If you follow this article verbatim it will not end in the result you are seeking.

Essentially the article is saying to have 2 columns where the checkboxes are linked to adjacent columns to enter in values which are then used for conditional formats. No one wants to have values associated in adjacent cells to checkboxes. Lastly, if this is the route you're going you're not linking checkboxes to conditional formats, you are linking checkboxes to cell values which are then in turn associated to conditional formats.

It is easier to just use icons instead of checkboxes (use the green checkmark icon) and create the conditional formats for a value of 1 or 0. If cell = 1 then it will replace the value with the icon and highlight your row. To accomplish this you use 2 conditional formats on your table.

Top left of table is B4, bottom right of table is L28

1st conditional format:
USE A FORMULA TO DETERMINE WHICH CELLS TO FORMAT
Formula: =$B4=1
Format: fill
Applies to: =$B4:$L28

2nd conditional format:
FORMAT CELLS BASED ON THEIR VALUES
Icon Set Custom
SHOW ICON ONLY (check this box off)
First icon (green checkmark) when value is > = 1 (type: number)
Second icon (no icon) when value is > = -1 (type: number)
Third icon (no icon) when < -1

Now, when I enter a 1 in B4 or any of the B column cells, it will highlight the entire row for me and replace the "1" with a checkmark.

BUILT-IN TEMPLATE WITH THIS FORMATTING:
1) Open Excel, search for a new template. Enter "Inventory" as the search term
2) Select the template titled "Inventory list with highlighting"
3) Highlight the first row of the table, open conditional formats to manage/edit. You will see the 2nd and 3rd formats are for highlights and the icon in the B column. You can change the icon to whatever you want. Remove the first format if you don't want the strikeout options from the Discontinued column.
This comment was minimized by the moderator on the site
I have a question about the initial step of linking the checkbox to a true/false.

1. Select the first check box in I1, enter formula =$J$1 into the formula bar, and then press the Enter key.

2. Repeat step 1 until all check boxes are linked to the adjacent cells.

For the repeat, does it have to be done for each cell or can you get the drag down to autofill? Right now, when I drag down the corner box it will autofill with =$J$1 for everything so that if I check one box, every box is checked. How can I fix this without manually linking each checkbox?
This comment was minimized by the moderator on the site
Hi,
The Fill Handle can't help in this case. You need to manually link each checkbox to its adjacent cell.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations