MSG Box based on cell values

ryan_law2000

Well-known Member
Joined
Oct 2, 2007
Messages
738
Hey Everyone,

So Im looking for a MSG Box "Warning to Big"
to appear only when a cell in Range M21:M500 is a bigger number then cell P4

Once the MSG box appears i dont want it to keep appearing unless that cell value that triggered it changes again

What would i do for that?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hey Everyone,

So Im looking for a MSG Box "Warning to Big"
to appear only when a cell in Range M21:M500 is a bigger number then cell P4

Once the MSG box appears i dont want it to keep appearing unless that cell value that triggered it changes again

What would i do for that?
Here's some sheet code that will do what you want.

To install the code:
1. Right-click the worksheet tab you want to apply it to and choose 'View Code'. This will open the VBE window.
2. Copy the code below from your browser window and paste it into the white space in the VBE window.
3. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
4. Make sure you have enabled macros whenever you open the file or the code will not run.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target, Range("M21:M500")) Is Nothing Then
    For Each c In Target
        If IsNumeric(c) Then
            If c.Value > Range("P4").Value Then
                MsgBox "WARNING - TOO BIG"
                Exit For
            End If
        End If
    Next c
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,210
Members
448,874
Latest member
b1step2far

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
Back
Top