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

Excelでセルの値が「X」に等しい場合にメッセージボックスをポップアップするにはどうすればよいですか?

メッセージボックスをポップアップすると、指定した範囲内の特定のコンテンツを見つけるのに非常に役立ちます。 たとえば、A50:C1の範囲で7に等しいセル値を検索していて、セル値が存在するかどうかを通知するメッセージボックスがポップアップする必要があります。 次のXNUMXつの方法が役立ちます。

セル値がVBAコードで「X」に等しい場合にメッセージボックスをポップアップします
セル値がKutoolsfor Excelで「X」に等しい場合、メッセージボックスを簡単にポップアップします


セル値がVBAコードで「X」に等しい場合にメッセージボックスをポップアップします

次のVBAコードは、特定の値が指定された範囲に存在する場合にポップアップメッセージボックスを作成するのに役立ちます。 次のようにしてください。

1.ワークシートで、指定した範囲の値を確認する必要があります。シートのタブバーでタブ名を右クリックし、[ コードを表示 右クリックメニューから。 スクリーンショットを参照してください:

セル値1の場合はドキュメントメッセージボックス

2。 の中に アプリケーション向け Microsoft Visual Basic ウィンドウで、次のVBAコードをコピーしてコードウィンドウに貼り付けます。

VBAコード:セル値が「X」に等しい場合にメッセージボックスをポップアップします

Private Sub Worksheet_Change(ByVal Target As Range)
'Update: 2017/7/25
    Dim xCell As Range, Rg As Range
    On Error Resume Next
    Set Rg = Application.Intersect(Target, Range("A1:C7"))
    If Not Rg Is Nothing Then
        For Each xCell In Rg
            If xCell.Value = "50" Then
                MsgBox "guest entered into cell " & xCell.Address, vbInformation, "Kutools for Excel"
                Exit Sub
            End If
        Next
    End If
End Sub
Private Sub Worksheet_selectionChange(ByVal Target As Range)
    Dim xCell As Range, Rg As Range
    On Error Resume Next
    Set Rg = Application.Intersect(Target, Range("A1:C7"))
    If Not Rg Is Nothing Then
        For Each xCell In Rg
            If xCell.Value = "50" Then
                MsgBox "guest entered into cell " & xCell.Address, vbInformation, "Kutools for Excel"
                Exit Sub
            End If
        Next
    End If
End Sub

3。 押す 他の + Q キーを同時に閉じて アプリケーション向け Microsoft Visual Basic ウィンドウをクリックして、ワークシートに戻ります。

これ以降、セル値が範囲A1:C7で変更され、セル値が「50」に等しい場合、以下のスクリーンショットに示すようなメッセージボックスが表示されます。

また、セル値が存在する場合は、範囲を選択するだけでメッセージボックスをポップアップできます。

セル値1の場合はドキュメントメッセージボックス

ノート:

1.セルの値が基準を満たしていない場合、メッセージボックスはポップアップしません。
2.上記のコードでは、必要に応じてセルの参照と値を変更できます。
3.複数の結果がある場合、一致するセル参照をXNUMXつだけ表示できます。

セル値がKutoolsfor Excelで「X」に等しい場合、メッセージボックスをポップアップします

  特定のセルを選択 の有用性 Kutools for Excel この問題の解決にも役立ちます。 次のようにしてください。

申請する前に Kutools for Excelについては 最初にダウンロードしてインストールします.

1.セル値が存在する場合に検索する範囲を選択し、[ クツール > 選択 > 特定のセルを選択

2。 の中に 特定のセルを選択 ダイアログボックスで セル 内のオプション 選択タイプ セクションを選択してから 等しいです 最初に 特定のタイプ ドロップダウンリストを表示し、次のテキストボックスにセルの値を入力して、最後に[ OK

セル値1の場合はドキュメントメッセージボックス

セル値が指定された範囲内に存在する場合は、次のメッセージボックスが表示されます。 OK ボタンをクリックすると、セルが選択されます。

セル値1の場合はドキュメントメッセージボックス

それ以外の場合は、以下のスクリーンショットに示すようなメッセージボックスが表示されます。

セル値1の場合はドキュメントメッセージボックス

  このユーティリティの無料トライアル(30日)が必要な場合は、 クリックしてダウンロードしてください、次に、上記の手順に従って操作を適用します。


セル値がKutoolsfor Excelで「X」に等しい場合、メッセージボックスを簡単にポップアップします


関連記事:

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

🤖 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 (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Is there a way to update for 2 values in the same range? ex "50" or "100" ?
This comment was minimized by the moderator on the site
Hi Rajesh,
The below code can help you solve the problem, please have a try. Thank you!

Private Sub Worksheet_Change(ByVal Target As Range)

'Update: 2020/8/21

Dim xCell As Range, Rg As Range

On Error Resume Next

Set Rg = Application.Intersect(Target, Range("A1:C7"))

If Not Rg Is Nothing Then

For Each xCell In Rg

If xCell.Value = "50" Or xCell.Value = "100" Then

MsgBox "guest entered into cell " & xCell.Address, vbInformation, "Kutools for Excel"

Exit Sub

End If

Next

End If

End Sub
This comment was minimized by the moderator on the site
Hi Crystal, Both conditions are working . Thank you so much ThanksRajesh
This comment was minimized by the moderator on the site
Is there a way to update for 2 values in the same range? ex "50" or "100" ?
This comment was minimized by the moderator on the site
I also tried duplicating this code, and changing to a different range where my data is repeated, but it appears the "Worksheet - Change" function can only be used once. Is this true?
This comment was minimized by the moderator on the site
This script works fine when the cell was enter manually. But when I try to copy the whole line from the other line and paste it to the new line, the pop up window will still come up even the cell on the new line didn't contain the key word. Any way to get rid of it? Please advice. Thanks
This comment was minimized by the moderator on the site
Dear TANGO, Thank you for your comment! We have updated the VBA script to get rid of the problem you mentioned above. Hope the new code can ease your work. If you have any problem, please do hesitate to contact us! Thanks again for your comment!
This comment was minimized by the moderator on the site
please need your help give me your email address Linda mine is
This comment was minimized by the moderator on the site
Hi,
Sorry for replying so late. Please contact me at .
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations