Msg Box based on a sum and another cell

jaycatuk

New Member
Joined
Oct 22, 2010
Messages
3
Hi
I want to be have a msg box pop up when the sum of a set of cells (range1) is more than the sum of another set of cells (range2). If range 1 > range 2 is true, then it needs to check a cell (A12) is not blank. If the cell is not blank, do nothing, if the cell is blank then pop up a message "you have too much".

So far i have:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("B26") > Range("B12") Then
MsgBox "WARNING: Total Development day costs are not enqual to total development days charged. Please provide explanation.", vbOK
End If
End Sub

Any help would be appreciated
Thanks
Jessica
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If (Range("B26").Value > Range("B12").Value) And .Range("A12") = "" Then
    MsgBox "WARNING: Total Development day costs are not equal to total development days charged. Please provide explanation."
End If
End Sub
 
Upvote 0
Hi
Thanks for this. How do i now use it to sum a group of cells and compare that sum to the sum of another group
Thanks
Jessica
 
Upvote 0
For the ranges, use something like:

Application.WorksheetFunction.Sum(Range("B1:B10"))
 
Upvote 0
Hi
Thanks for this, one last question. If i have multiple msg boxes that i want based on different criteria do i just put them one after another and they will work? ie
Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
        
    If Range("B26").Value > Range("B12").Value And Range("E26").Value = "" Then
        MsgBox "WARNING: Total Development day costs are not enqual to total development days charged. Please provide explanation.", vbOK
    Else

    End If
End Sub

Private Sub Worksheet_Change2(ByVal Target As Range)
        
    If Range("E64").Value < 100000 And Range("B70").Value = "" Then
        MsgBox "WARNING: Add explaination of why contribution too little.", vbOK
    Else

    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,379
Messages
6,124,609
Members
449,174
Latest member
ExcelfromGermany

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