Olá pessoal, tudo bom?
Preciso de uma ajuda!
Tenho um formúlario onde preencho vários campos de cadastro, quando for "Inclusão", ao aperta o botão de informar que concluiu o preenchimento, ele roda um job verificando algumas celulas que botei como prioritarias, com base em IFs, daí abre o email. A questão é que quando for "Alteração", ao apertar o botão, ele ja abra direto o e-mail, não rode a verificação.
Já utilizei Select Case, mas a macro ta rodando sem eu apertar o botão, alguem saberia me ajudar?
Sub Validar_botao_SUPPLY()
If Range("D12") = "" Then
MsgBox ("Preencher Família Plan. Mestre")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(12, 4).Select
ElseIf Range("D19") = "" Then
MsgBox ("Preencher Tipo de Estoque")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(19, 4).Select
ElseIf Range("D20") = "" Then
MsgBox ("Preencher Tipo de Linha")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(20, 4).Select
ElseIf Range("D21") = "" Then
MsgBox ("Preencher Planejador")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(21, 4).Select
ElseIf Range("D28") = "" Then
MsgBox ("Preencher Cod. Planej.")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(28, 4).Select
ElseIf Range("D29") = "" Then
MsgBox ("Preencher Regra de Limite de Tempo Plane.")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(29, 4).Select
ElseIf Range("D30") = "" Then
MsgBox ("Preencher Limite de Tempo de Planej.")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(30, 4).Select
ElseIf Range("D35") = "" Then
MsgBox ("Preencher Nível de Leadtime")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(35, 4).Select
ElseIf Range("D36") = "" Then
MsgBox ("Preencher Limite de Tempo de Exibição de Mensagem")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(36, 4).Select
ElseIf Range("D40") = "" Then
MsgBox ("Preencher Qtde. Máxima de Reposição")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(40, 4).Select
ElseIf Range("D41") = "" Then
MsgBox ("Preencher Mínima de Reposição (MRP)")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(41, 4).Select
ElseIf Range("D43") = "" Then
MsgBox ("Preencher Qtd. Pedido Múltiplo (MRP)")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(43, 4).Select
ElseIf Range("D44") = "" Then
MsgBox ("Preencher Estoque Segurança")
ActiveWorkbook.Sheets("DADOS - SUPPLY").Cells(44, 4).Select
Else
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Para = "
[email protected]"
Set rng = Nothing
On Error Resume Next
Set rng = Nothing
On Error GoTo 0
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Para
.Subject = ActiveWorkbook.Sheets("Índice").Cells(6, 10)
.HTMLBody = "Informo que concluí o preenchimento dos dados que sou responsável"
.Display
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub
Como anexei, caso um campo X estiver escrito Inclusão, ao clicar no botão, ele roda o codigo acima, caso o campo X estiver escrito Alteração, ele ja joga direto para a açao de abrir o e-mail.
alguem poderia me ajudar?