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)
For i = 15 To 100 'supondo que os endereços de e-mail estão entre a linha 15 até a 100. Ajuste isso.
linha = ActiveCell.Row - 1
'If Target.Address = "$M$" & linha Then
If Range("M2").Value <> PrevVal 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
PrevVal = Range("M2").Value
With OutMail
.to = "" & Planilha10.Cells(i, 15) & ""
.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
Next i
End sub