Message Box if cell value not in specific range

  • Thread starter Thread starter Marino13
  • Start date Start date
M

Marino13

How do I display a message box if a specific cell does not equal a given
number (say 100)?

Assume that I have two worksheets (Sheet1 and Sheet2) in a workbook.
If cell b7 in Sheet1 does not equal 100, I would like a message box to
appear to the user stating "Please review the numbers." The only
control for the message box should be an OK button.

After the OK button is clicked, it should return the user to cell a1 in
Sheet1.
 
why don't you use the data validation in excel. >> click data then validation and fill in the relevant details.
Otherwise insert this code onto the worksheet..

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B7") <> 100 Then
MsgBox ("Please revise the numbers")
Range("A1").Select
End If
End Sub

This will promt the user about the error evertime the sheet is changed.
 
Back
Top