Send email when Excel worksheet/workbook updated

TheJay

Active Member
Joined
Nov 12, 2014
Messages
364
Office Version
  1. 2019
Platform
  1. Windows
Hello there, I've seen other threads demonstrating that this is possible. I'm wondering if it is possible for a range of worksheets and to stop it happening on any that aren't listed?

I've added this to "ThisWorkbook"

I know I've got the code wrong, because I am getting an error about sh not being defined and am looking for corrections to get it working please:

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

  Select Case Sh.Name
        Case "HA", "Ls", "Dev"
        .Range("A:E").Select '#
    ActiveWorkbook.EnvelopeVisible = True
        With ActiveSheet.MailEnvelope
        .Introduction = "Hello NAME, the worksheet has been updated by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm")
        .Item.To = "MYEMAILADDRESS"
        .Item.Subject = "Worksheet Updated"
        .Item.display
        '.Item.send
    End With
        Case Else
    ActiveWorkbook.EnvelopeVisible = False
    End Sub

Thank you very much.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,215,516
Messages
6,125,280
Members
449,220
Latest member
Excel Master

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