Hi.
Please could someone review the code below and tell me if it is possible to adapt the event worksheet to work through the formula.
This code is great, works just right for my needs, but it only works when I do manual entry but the cell that will be changed in my spreadsheet and what is the trigger is changed by formula. I realized that if I give a formula enter the code works.
Please could someone review the code below and tell me if it is possible to adapt the event worksheet to work through the formula.
This code is great, works just right for my needs, but it only works when I do manual entry but the cell that will be changed in my spreadsheet and what is the trigger is changed by formula. I realized that if I give a formula enter the code works.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim OutApp As Object
Dim OutMail As Object
Dim texto As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
linha = ActiveCell.Row - 1
If Target.Address = "$I$" & linha Then
If Plan2.Cells(linha, 9) = "Menos de 15 Dias p/ o Prazo" Then
texto = "Prezado(a)" & Plan2.Cells(linha, 4) & "," & vbCrLf & vbCrLf & _
"A ação " & Plan2.Cells(linha, 2) & _
"irá vencer em 15 dias." & vbCrLf & _
"Atenciosamente," & vbCrLf & _
"EHS"
End If
With OutMail
.To = Plan2.Cells(linha, 4)
.CC = "tiago.ferreira.luz@delphi.com"
.BCC = ""
.Subject = "Ação a vencer"
.Body = texto
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub