Pop-Up Message for only when a cell's value changes and not when other cells change

lucy61176

New Member
Joined
Jun 11, 2014
Messages
36
I want to create a pop-up message for two of the cells that contain a formula. Cell A10 counts dates entered in column A for the current calendar year. E10 totals the hours and minutes in column E. I was able to create the following code:



Private Sub Worksheet_Calculate()
If Range("A10").Value > 3 Then MsgBox "Employee has reached the tardy threshold. Contact HR Coordinator."
If Range("E10").Value > 2.667 Then MsgBox "Employee has reached the 64-hour threshold for sick leave. Contact HR Coordinator. If employee provides medical verification, enter hours over 64, using calculator on the right, in a new row under the Pre-Approved and Authorized Absences section."
End Sub



I would like it to pop up when the total is => a certain value. I would not like it to pop up if data in other cells outside that column is entered (right now it seems to pop up once the condition is met everywhere on the sheet). If the user deletes rows and it makes the total < the certain value, I would not like it to pop up, but if the user adds more data again to make the total => the value, I would like it to pop up again. This is a dynamic, ever-changing sheet, but I am not sure how to make it work this way.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The Worksheet_Calculate event procedure is triggered when any formula is re-calculated on the worksheet.

Use the Worksheet_Change event procedure instead. It's triggered when the user changes the worksheet. The code below evaluates if the user-change occurred in column A or E and displays the appropriate message based on the values in A10 and E10.

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] Worksheet_Change([color=darkblue]ByVal[/color] Target [color=darkblue]As[/color] Range)
    [color=darkblue]If[/color] Target.Count = 1 [color=darkblue]Then[/color]
        [color=darkblue]If[/color] Target.Column = 1 [color=darkblue]Then[/color]       [color=green]'Column A changed[/color]
            [color=darkblue]If[/color] Range("A10").Value > 3 [color=darkblue]Then[/color] MsgBox "Employee has reached the tardy threshold. ", , "Contact HR Coordinator."
        [color=darkblue]ElseIf[/color] Target.Column = 5 [color=darkblue]Then[/color]   [color=green]'Column E changed[/color]
            [color=darkblue]If[/color] Range("E10").Value > 2.667 [color=darkblue]Then[/color]
                MsgBox "Employee has reached the 64-hour threshold for sick leave. " & vbLf & vbLf & _
                       "If employee provides medical verification, enter hours over 64, using calculator on the right, " & vbLf & _
                       "in a new row under the Pre-Approved and Authorized Absences section.", , _
                       "Contact HR Coordinator."
            [color=darkblue]End[/color] [color=darkblue]If[/color]
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]End[/color] [color=darkblue]If[/color]
End [color=darkblue]Sub[/color]
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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