Easy one - Message Box

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
583
I need a macro that will do this:

Generate a pop-message each time the user enter the wrong data in a cell (cell Q4).
Only numbers between 10 and 18 (inclusive) and the word "CAD" should be entered in the cell. I want the message box to pop up if unauthorized data is entered in the cell.

Thanks for your help.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

paliman

Active Member
Joined
Jul 7, 2002
Messages
254
In the menu:
data
validate (or something like that)

You can set the conditions for the data to be entered and the text in the message box for bad entries

pali
 

ExcelNovice

Well-known Member
Joined
May 12, 2002
Messages
583
Thanks Pali, but Validation won't work because the cell have to be able to take both text and values. As far as I know, validation is either text or value.

If someone else have an idea please let me know.

Thanks
 

kskinne

Well-known Member
Joined
Feb 17, 2002
Messages
1,267
Office Version
  1. 365
Platform
  1. Windows
insert the following code into your worksheet's object window

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 17 And Target.Row = 4 Then
If Target.Value = "CAD" Then
End
ElseIf Target.Value >= 10 And Target.Value <= 18 Then
End
Else
MsgBox "Wrong Data"
End
End If
Else
End
End If
End Sub

HTH
kevin
 

Dragracer

Board Regular
Joined
Jun 9, 2002
Messages
151
Validation will also work.

You can choose list for your criteria, then enter all your values separated by comas or use a named range with the values listed somewhere in your workbook.

or choose custom for your criteria and enter a if formula. I believe this formula will work for you.

=IF(OR(Q4="CAD",AND(Q4<=18,Q4>=10)),TRUE,FALSE)

may not be elegent but it works

edited to revise formula
This message was edited by Dragracer on 2002-09-23 16:36
 

Forum statistics

Threads
1,143,707
Messages
5,720,387
Members
422,282
Latest member
psunith

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top