ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Message Box if sum is above 30 (https://www.excelbanter.com/excel-programming/352579-message-box-if-sum-above-30-a.html)

Elaine

Message Box if sum is above 30
 
If A3, B3 and C3 in a sheet add up to over 30 I would like to automatically
warn the user with a message box. Is it possible to put the amount these
three cells add up to as well?

If these cells add up to 30 or less then I don't want anything to happen.

Any help would be appreciated. Thank you.

--Elaine

Dave Peterson

Message Box if sum is above 30
 
I find just using a cell close to those other cells the best way to tell the
users:

Maybe D3???

=if(sum(a3:c3)<=30,"","Too much in A3:C3!")

I'd format it in big bold red letters.

Elaine wrote:

If A3, B3 and C3 in a sheet add up to over 30 I would like to automatically
warn the user with a message box. Is it possible to put the amount these
three cells add up to as well?

If these cells add up to 30 or less then I don't want anything to happen.

Any help would be appreciated. Thank you.

--Elaine


--

Dave Peterson

Jim Thomlinson[_5_]

Message Box if sum is above 30
 
Are A3, B3 and C3 constants or formulas or a mixture of the two?
--
HTH...

Jim Thomlinson


"Elaine" wrote:

If A3, B3 and C3 in a sheet add up to over 30 I would like to automatically
warn the user with a message box. Is it possible to put the amount these
three cells add up to as well?

If these cells add up to 30 or less then I don't want anything to happen.

Any help would be appreciated. Thank you.

--Elaine


Jim Thomlinson[_5_]

Message Box if sum is above 30
 
Here is some code to try. It is a bit overkill if you only have constants in
A3:C3 but it will work. Place this code directly in the sheet (Right click
the sheet tab and select view code)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
On Error Resume Next
Set rng = Intersect(Range("A1:A3"), Target.Dependents)
If rng Is Nothing Then Set rng = Intersect(Range("A1:A3"), Target)
On Error GoTo 0
If Not (rng Is Nothing) And Application.Sum(Range("A1:A3")) 30 Then
MsgBox Application.Sum(Range("A1:A3"))
End If
End Sub
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Are A3, B3 and C3 constants or formulas or a mixture of the two?
--
HTH...

Jim Thomlinson


"Elaine" wrote:

If A3, B3 and C3 in a sheet add up to over 30 I would like to automatically
warn the user with a message box. Is it possible to put the amount these
three cells add up to as well?

If these cells add up to 30 or less then I don't want anything to happen.

Any help would be appreciated. Thank you.

--Elaine



All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com