Pop-up message if specific cells contain value

gato88

New Member
Joined
Feb 10, 2014
Messages
25
Hi there

I would like to generate a pop-up message "Warning! Please check value!" if any of the following cells A4, D5, G7 contain any character.

Thank you in advance!
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

BrianJN1

Well-known Member
Joined
Jun 15, 2017
Messages
603
Haven't tested but try this:

If range("A4").value <>"" or range("D5").value <>"" or range("G7").value <>"" then
MsgBox("Warning! Please check value!")
End if

One way or another this is what you appear to be seeking.
 

SyedUsman

Board Regular
Joined
Jun 28, 2017
Messages
117
GO TO VBA EDITOR

SELECT THE DESIRED SHEET & PASTE THE FOLLOWING CODE

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Range("A4,D5,G7").Value <> "" Then MsgBox ("Warning! Please check value!")


End Sub
 

gato88

New Member
Joined
Feb 10, 2014
Messages
25
GO TO VBA EDITOR

SELECT THE DESIRED SHEET & PASTE THE FOLLOWING CODE

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Range("A4,D5,G7").Value <> "" Then MsgBox ("Warning! Please check value!")


End Sub

Is it possible for the warning to appear only once after text is input in any of these 3 cells.
Once I click "OK" and proceed to input a value in any other cell on the worksheet, the warning still pops up on screen. I woud like the warning to only appear once.
 

gato88

New Member
Joined
Feb 10, 2014
Messages
25
Hi I tried this code and it seems to be doing what I want.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A4,D5,G7")) Is Nothing Then Exit Sub
If Target.Value <> "" Then MsgBox "Please check value!", vbExclamation
End Sub


However, if the user deletes a value from any of the target cells, I get a runtime error (as per below)

Error 13: Type mismatch highlighting the following line
If Target.Value <> "" Then
 
Last edited:

gato88

New Member
Joined
Feb 10, 2014
Messages
25
Is it possible to stop the "worksheet_change" sub after the msgbox appears on screen?
 

Watch MrExcel Video

Forum statistics

Threads
1,099,574
Messages
5,469,475
Members
406,655
Latest member
pwilson06

This Week's Hot Topics

Top