Here's an example Excel VBA code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim EmailAddress As String
Dim EmailBody As String
Dim EmailSubject As String
Dim Mail_Object As Object
If Target.Column = 3 Then 'Column C is being monitored for changes
EmailAddress = Sheets("Email Addresses").Range("A2").Value 'Change A2 to the location of the email address cell in the Email Addresses sheet
EmailSubject = "Update Notification" 'Change the email subject to your preference
EmailBody = "A change has been made in the sheet." & vbCrLf & _
"Cell address: " & Target.Address & vbCrLf & _
"New value: " & Target.Value 'The email body includes information about the changed cell
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
.Subject = EmailSubject
.To = EmailAddress
.Body = EmailBody
.Send
End With
Set Mail_Object = Nothing
End If
End Sub
In this example, the code is attached to the worksheet where you want the email notification to occur. It monitors changes in column C by checking if the modified cell's column is equal to 3. If so, it retrieves the email address from cell A2 in the "Email Addresses" sheet, creates an email with the specified subject and body, and sends it using Microsoft Outlook.
Make sure to enable macros and allow Outlook access if prompted when running the code. Also, modify the code as necessary to suit your needs, such as changing the monitored column, email address cell location, email subject, and body.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-12-24 11:00:00 +0000
Seen: 18 times
Last updated: Jan 22 '23
What is a WordPress web address that includes a system of hierarchical taxonomies?
How to address NPM vulnerabilities?
How can actual IP be utilized to establish connectivity between WSL2 and the host?
How to locate the server address that is the destination for gRPC requests?
The stacktrace appears to be incomplete when using clang address sanitizer.
When using k3d, how can you specify a customized docker socket address?
How to establish a connection between Ionic BLE and a device's Mac Address on iOS?
Can the https address be utilized via the --urls parameter in the Web API Service?