Bom dia!
Estou com esse macro que roda automaticamente, porém ele só está enviando e-mail quando eu edito qualquer célula da coluna M manualmente, mas preciso que ele envie quando qualquer célula da coluna M mudar via fórmula.
Private Sub Worksheet_Change(ByVal Target As Range)
'Envia e-mail pelo Outlook
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 = "$M$" & linha Then
If Planilha10.Cells(linha, 13) = "Sim" Then
texto = "Prezado(a), " & vbCrLf & vbCrLf & _
"O item: " & Planilha10.Cells(linha, 3) & " necessita de reparo" & "." & vbCrLf & vbCrLf & _
End If
If Planilha10.Cells(linha, 13) = "Não" Then
texto = "Prezado(a), " & vbCrLf & vbCrLf & _
"Foi reparado o item: " & Planilha10.Cells(linha, 3) & vbCrLf & vbCrLf & _
End If
With OutMail
.To = "e-mail para quem deseja enviar"
.CC = ""
.BCC = ""
.Subject = "Título do e-mail"
.Body = texto
.Display 'Utilize Send para enviar o email sem abrir o Outlook
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub