Help - Simple Macro (If Sum of Row>0, Then MsgBox, Else, Macro2)

JonesyUK

Board Regular
Joined
Oct 11, 2005
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Need your help please:

My spreadsheet contains a Macro ("SendEmail") which, when activated, will send the spreadsheet to a specific email address. It works fine.

I would like to add a new Macro that Checks the following, BEFORE running the "SendEmail" Macro:

1) If Sum(C52:M53)<=1, MsgBox "Please Enter your Data in Rows 22 & 23"
2) If Sum(C97:M97)>0, MsgBox "Please Check your Data Breakdown"
3) If Sum(C52:M53) >1 AND Sum(C97:M97)=0, Then "SendEmail"

Many Thanks for your expertise....
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
If WorksheetFunction.Sum(Range("C52:M53")) <= 1 Then
    MsgBox "Please Enter your Data in Rows 22 & 23"
    Exit Sub
End If
If WorksheetFunction.Sum(range("C97:M97")) > 0 Then
    MsgBox "Please Check your Data Breakdown"
    Exit Sub
End If
Call SendEmail
 
Upvote 0

JonesyUK

Board Regular
Joined
Oct 11, 2005
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Thanks for that... your first If statement works fine. However, it seems to ignore the second If statement. Does it matter that there are formulas in the cells in C97:M97?
 
Upvote 0

JonesyUK

Board Regular
Joined
Oct 11, 2005
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Not to worry - my mistake... works perfectly.... Thanks!
 
Upvote 0

Forum statistics

Threads
1,195,937
Messages
6,012,410
Members
441,698
Latest member
DaveTeo

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
Top