Auto email before save if criteria is met

snowboy001

Board Regular
Joined
Dec 5, 2009
Messages
100
I have some macro's that are tracking changes on each sheet in my workbook. If there are changes detected, it puts a "1" in cell A1 of a hidden sheet (named "Sheet1" for this demonstration). I am wanting to run a BeforeSave event to check for that "1", and if it is there, send an email out to my group to notify them.

Here is what I am thinking...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

'run macros to update changes, and put a "1" in cell A1 of the hidden sheet
If Sheets("Sheet1").Range("A1").Value = "1" Then
'code to send out email to my group (I already have this code)
End If
End Sub

The part in red is what I am having trouble with.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

snowboy001

Board Regular
Joined
Dec 5, 2009
Messages
100
Still doesn't work. Usually when I type Sheets("Sheet1"). it pulls up a list of values, and in this module, it is not even doing that. Kind of like it's not enen acknowledging the command.
 

snowboy001

Board Regular
Joined
Dec 5, 2009
Messages
100
Oops! I guess I didn't realize that had to be in there. It works great now! Thanks!!!
 

Watch MrExcel Video

Forum statistics

Threads
1,132,911
Messages
5,655,907
Members
418,250
Latest member
Jebacmakro

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